struts显示列表出错!大家帮帮手

win3721 2004-09-18 09:04:01
出错信息:
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Cannot find bean userActionForm in scope request


jsp文件:
<%@ page contentType="text/html; charset=GBK" %>

<%@ 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>
logon
</title>
</head>
<body bgcolor="#ffffff">
<h1> 用户列表:</h1>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="30%">
<div align="center">用户ID</div></td>
<td width="30%">
<div align="center">用户名</div></td>
<td width="30%">
<div align="center">密码</div></td>
</tr>
<logic:iterate id="userListAction" name="userActionForm" scope="request" type="com.jansky.weboa.entity.userActionForm">
<tr>
<td> <bean:write name="userActionForm" property="user_id"/></td>
<td> <bean:write name="userActionForm" property="user_name"/></td>
<td> <bean:write name="userActionForm" property="user_pwd"/></td>
</tr>
</logic:iterate>
</table>
<p> </p>
<center>
<html:errors />
</center>
<br>
</body>
</html:html>

struts-config.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean name="userActionForm" type="com.jansky.weboa.entity.userActionForm" />
</form-beans>
<action-mappings>
<action input="userList.jsp" path="/userListAction" scope="request" type="com.jansky.weboa.action.userListAction" validate="true">
<forward name="success" path="/userList.jsp" redirect="false" />
<forward name="add" path="/userAdd.jsp" redirect="false" />
</action>
</action-mappings>
</struts-config>
...全文
103 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
popufig 2004-09-19
  • 打赏
  • 举报
回复
晕,怎么就发出去了??

Action改为:
Collection col = user.userList();
httpServletRequest.setAttribute("list", col);
return actionMapping.findForward("success");

jsp:

<logic:iterate id="userListAction" name="list" scope="request" type="com.jansky.weboa.entity.userActionForm">
<tr>
<td> <bean:write name="userListAction" property="user_id"/></td>
<td> <bean:write name="userListAction" property="user_name"/></td>
<td> <bean:write name="userListAction" property="user_pwd"/></td>
</tr>
</logic:iterate>
popufig 2004-09-19
  • 打赏
  • 举报
回复
Action改为:
Collection col = user.userList();
httpServletRequest.setAttribute("userActionForm", col);
return actionMapping.findForward("success");
win3721 2004-09-18
  • 打赏
  • 举报
回复
Action如下:
package com.jansky.weboa.Action;

import com.jansky.weboa.entity.*;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
import com.jansky.weboa.db.connPool;
import com.jansky.weboa.db.userDAO;
public class userListAction extends Action {
private connPool pool;
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
// userActionForm userActionForm = (userActionForm) actionForm;
// throw new java.lang.UnsupportedOperationException("Method perform() not yet implemented.");
Connection con=null;
con = pool.connPool();
userDAO user = new userDAO(con);
Collection col = user.userList();
httpServletRequest.setAttribute("userActionForm", col);
return actionMapping.findForward("success");

}

}
ActionForm如下:

package com.jansky.weboa.entity;
/**
*Title:实体建模
*Description:定义表user中列项的属性
*Time:2004-9-15
*Company:jansky
*Author:黄晓华
*version1.0
*/
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.util.ArrayList;
public class userActionForm extends ActionForm {
private String user_id;
private String user_name;
private String user_pwd;
public String getUser_id() {
return user_id;
}
public void setUser_id(String user_id) {
this.user_id = user_id;
}
public String getUser_name() {
return user_name;
}
public void setUser_name(String user_name) {
this.user_name = user_name;
}
public String getUser_pwd() {
return user_pwd;
}
public void setUser_pwd(String user_pwd) {
this.user_pwd = user_pwd;
}
public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
/**@todo: finish this method, this is just the skeleton.*/
return null;
}
public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
}
}
win3721 2004-09-18
  • 打赏
  • 举报
回复
还是不行哦
popufig 2004-09-18
  • 打赏
  • 举报
回复
<logic:iterate id="userListAction" name="userActionForm" scope="request" type="com.jansky.weboa.entity.userActionForm">
<tr>
<td> <bean:write name="userListAction" property="user_id"/></td>
<td> <bean:write name="userListAction" property="user_name"/></td>
<td> <bean:write name="userListAction" property="user_pwd"/></td>
</tr>
</logic:iterate>

改成上面的应该ok!
homecat 2004-09-18
  • 打赏
  • 举报
回复
你的ACTION中的VO传回的值要与你的JSP页面中的LOGIC中的NAME值一样,你才能正确的取到值
朋友别哭 2004-09-18
  • 打赏
  • 举报
回复
up
showerXP 2004-09-18
  • 打赏
  • 举报
回复
Cannot find bean userActionForm in scope request


说的很清楚。

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧