求助:Cannot find bean in scope request
<<GroupServices.java文件>>
package com.mcc.services;
import java.util.List;
import java.util.ArrayList;
import com.mcc.form.GroupForm;
import com.kj.mcc.db.ea.bean.TblGroupinfo;
import com.kj.mcc.db.ea.HiberEaDb;
import com.kj.mcc.db.ea.HiberEaDbImpl;
import com.kj.mcc.properties.QueryPropertie;
public class GroupServices
{
public List selectGroup()
{
HiberEaDb hdb = new HiberEaDbImpl();
QueryPropertie qp = new QueryPropertie();
qp.setStrHql("select vw.name,vw.departcode,vw.note from vw_groupinfo as vw");
List list = hdb.selectList(qp);
return list;
}
<<Action文件>>
package com.mcc.action;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.Action;
import java.util.*;
import com.mcc.form.ParameterForm;
import com.mcc.services.GroupServices;
public class GroupAction extends Action
{
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response)
{
ParameterForm form = (ParameterForm)actionForm;
GroupServices gs = new GroupServices();
List list = new ArrayList();
list = gs.selectGroup();
request.setAttribute("groupList", list);
return actionMapping.findForward("2");
}
}
<<JSP文件>>
<%@page contentType="text/html; charset=gb2312"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<html:html>
<head>
<title>专业组设定</title>
</head>
<body bgcolor="#ffffff">
<h3 align="center">专业组设定</h3>
<html:form action="Group" method="post">
<table border="1" align="left" width="80%" cellpadding="1" cellspacing="2">
<tr><th width="20%">名称</th><th width="20%">部门</th><th width="40%">备注</th></tr>
<logic:present name="groupList" scope="request">
<logic:iterate id="group" name="groupList" scope="request">
<tr>
<th width="20"><bean:write name="group" property="name"/></th>
<th width="20"><bean:write name="group" property="depart"/></th>
<th width="40"><bean:write name="group" property="note"/></th>
</tr>
</logic:iterate>
</logic:present>
</table>
</html:form>
</body>
</html:html>
程序运行后抛出异常Cannot find bean groupList in scope request
此问题自己搞了一天,也没有解决,请教高手,不胜感激
问题点数:50、回复次数:9Top
1 楼kevinliuu()回复于 2006-07-03 20:29:30 得分 0
在jsp页面中使用request.getAttribute("groupList"); 看看是不是nullTop
2 楼lfaviate()回复于 2006-07-04 08:38:32 得分 0
是空的啊 请问怎么解决呢Top
3 楼dreamover(梦醒了〖http://hellfire.cn〗)回复于 2006-07-04 08:49:16 得分 0
那就再试试action里setAttribute之前list是不是空的,再试试List list = hdb.selectList(qp)后的list是不是空的
追本溯源呗
另:
List list = new ArrayList();
list = gs.selectGroup();
这是神经写法Top
4 楼lfaviate()回复于 2006-07-04 08:51:48 得分 0
我发现没有执行Action 啊Top
5 楼kevinliuu()回复于 2006-07-04 08:55:42 得分 0
倒~Top
6 楼kevinliuu()回复于 2006-07-04 08:56:13 得分 0
你的struts配置文件有问题Top
7 楼lfaviate()回复于 2006-07-04 08:59:44 得分 0
我在Action里System.out.println("Action is start");
控制台没有输出Top
8 楼lfaviate()回复于 2006-07-04 09:00:16 得分 0
初学struts 都被搞晕了Top
9 楼lfaviate()回复于 2006-07-04 09:01:03 得分 0
这是struts配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="ParameterForm" type="com.mcc.form.ParameterForm" />
<form-bean name="GroupForm" type="com.mcc.form.GroupForm" />
</form-beans>
<action-mappings>
<action input="Parameter.jsp" name="ParameterForm" path="/Parameter" scope="session" type="com.mcc.aciton.ParameterAction">
<forward name="1" path="/ParameterForm.jsp" />
</action>
<action input="Group.jsp" name="GroupForm" path="/Group" scope="session" type="com.mcc.action.GroupAction">
<forward name="2" path="/Group.jsp" />
</action>
</action-mappings>
<message-resources parameter="ApplicationResources" />
</struts-config>
Top




