2010-04-20 11:50:29,406 ERROR [org.apache.struts.actions.DispatchAction] - Request[/role] does not contain handler parameter named 'operate'. This may be caused by whitespace in the label text.
2010-04-20 11:50:29,406 ERROR [org.apache.struts.actions.DispatchAction] - Request[/user] does not contain handler parameter named 'operate'. This may be caused by whitespace in the label text.
仔细检查下是不是传参数的时候存在空格什么的.
<title>用户列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="${path}/css/style.css" rel="stylesheet" type="text/css">
<script src="${path}/script/common.js"></script>
<script type="text/javascript">
function doDel(userId){
if( ! confirm("是否删除") ){
return false;
}
window.location.href="${path}/user.do?o=doDel& userId="+userId;
}
function toAdd(){
window.location.href="${path}/user.do?o=toAdd";
}
function doCheck(){
document.forms[0].submit();
}
</script>
</head>
<body>
<tagUtil:erralert errcode="msg"/>
<div class="page_title">
用户管理
</div>
<div class="button_bar">
<button class="common_button" onclick="toAdd()">
新建
</button>
<button class="common_button" onclick="doCheck();">
查询
</button>
</div>
<html:form action="/user" method="post">
<html:hidden name="o" value="toList"/>
<table class="query_form_table">
<tr>
<th>
用户名:
</th>
<td>
<html:text property="user.usrName"></html:text>
</td>
<th>
状态
</th>
<td>
<html:select property="user.usrFlag">
<html:option value="-1">全部</html:option>
<html:option value="0">已删除</html:option>
<html:option value="1">正常</html:option>
</html:select>
</td>
</tr>
</table>
<br />
<table class="data_list_table">
<tr>
<th class="data_title" style="width: 40px;">
编号
</th>
<th class="data_title" style="width: 35%;">
用户名
</th>
<th class="data_title" style="width: 35%;">
状态
</th>
<th class="data_title">
操作
</th>
</tr> <logic:iterate id="item" name="userForm" property="presult.list" indexId="index">
<tr>
<td class="list_data_number">
${index +1}
</td>
<td class="list_data_text">
${item.usrName}
</td>
<td class="list_data_text">
${item.usrFlag==0?"已删除":"正常"}
</td>
<td class="list_data_op">
<c:if test="${item.usrFlag != 0}">
<img class="op_button"
onclick="window.location.href='?o=toDetail&id=${item.usrId }'"
src="images/bt_detail.gif" title="查看" />
<img class="op_button"
onclick="window.location.href='?o=toEdit&id=${item.usrId }'"
src="images/bt_edit.gif" title="编辑" />
<img class="op_button"
onclick="window.location.href='?o=toAssignRole&id=${item.usrId }'"
src="images/bt_linkman.gif" title="分配角色" />
<img onclick="doDel(${item.usrId })" title="删除"
src="images/bt_del.gif" class="op_button" />
</c:if>
<c:if test="${item.usrFlag == 0}">
<img class="op_button"
onclick="window.location.href='?o=doUser&userId=${item.usrId }'"
src="images/other.gif" title="恢复用户" />
</c:if>
</td>
</tr>
</logic:iterate>
<!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="userForm" type="com.crm.auth.web.form.UserForm"/>
<form-bean name="roleForm" type="com.crm.auth.web.form.RoleForm"/>
</form-beans> <action-mappings>
<action path="/user" name="userForm" parameter="o" scope="request"
type="com.crm.auth.web.action.UserAction">
<forward name="toList" path="/pages/auth_pages/userlist.jsp"/>
</action>
<action path="/role" attribute="roleForm"
parameter="o" name="roleForm" scope="request">
<forward name="toList" path="/pages/auth_pages/rolelist.jsp"></forward>
</action>
<action path="/right" parameter="o" scope="request">
<forward name="getAll" path="/pages/auth_pages/roleModule.jsp"></forward>
<forward name="update" path="/role.do?o=toList"></forward>
</action>
</action-mappings></struts-config>
<action path="/right" parameter="o" scope="request">
<action path="/role" attribute="roleForm" parameter="o" name="roleForm" scope="request">是不是少了个type
还是谢谢了,等会就把分给你们
this.userBiz = userBiz;
} private SysRoleBiz roleBiz; public void setRoleBiz(SysRoleBiz roleBiz) {
this.roleBiz = roleBiz;
} /**
* 登入
*/
public ActionForward doLogin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UserForm userForm = (UserForm) form;
try {
SysUser user = userForm.getUser();
int res = userBiz.login(user);
if (res == 1) {
// 登录成功
request.getSession().setAttribute("user", user);
return mapping.findForward("g_index");
} else if (res == 0) {
request.setAttribute("msg", "请检查用户名跟密码是否正确!");
return mapping.getInputForward();
} else {
request.setAttribute("msg", "该用户不可用!");
return mapping.getInputForward();
}
} catch (Exception e) {
logger.error("登录时产生异常", e);
request.setAttribute("msg", "系统忙!");
return mapping.getInputForward();
}
} /**
* 登出
*/
public ActionForward doLogout(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession(false);
if (session != null)
session.invalidate();
// 使用全局转发到登录页
// <global-forwards>
// <forward name="g_index" path="/index.jsp"></forward>
// <forward name="g_r_login" redirect="true"
// path="/login.jsp"></forward>
// </global-forwards>
return mapping.findForward("g_r_login");
} /**
* 用户列表查询
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward toList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
try {
UserForm userForm = (UserForm) form;
SysUser user = userForm.getUser(); this.userBiz.findListByPage(user, userForm.getPresult()); PageResult<SysUser> pageResult = userForm.getPresult();
// 将pageResult对象存入Request中,供页面分页标签显示
request.setAttribute("pageResult", pageResult); } catch (Exception e) {
logger.error("查询用户出错", e);
request.setAttribute("msg", "系统忙!");
return mapping.getInputForward();
} return mapping.findForward("toList");
} /**
* 用户删除
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward doDel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
try {
HttpSession session=request.getSession();
String userName=((SysUser) session.getAttribute("user")).getUsrName();
// 获取用户Id
String uid = request.getParameter("userId"); Long userId = 0l; if (!CommonUtil.isEmptyOrNull(uid)) {
userId = Long.parseLong(uid);
} // 删除用户
SysUser sysUser = userBiz.findById(userId); if (sysUser.getSysRole() != null) {
if (sysUser.getSysRole().getRoleId() == 1) { request.setAttribute("msg", "不能删除管理员");
} else if( sysUser.getUsrName().equals(userName)){
request.setAttribute("msg", "不能删自己");
} else {
sysUser.setUsrFlag(0);
userBiz.delete(sysUser);
request.setAttribute("msg", "删除用户成功");
}
} else if( sysUser.getSysRole().getRoleName().equals(((SysUser) session.getAttribute("user") ).getUsrName())){
request.setAttribute("msg", "不能删自己");
}else {
sysUser.setUsrFlag(0);
userBiz.delete(sysUser);
request.setAttribute("msg", "删除用户成功");
}
/**
* 获取用户列表
*/
UserForm userForm = (UserForm) form;
SysUser user = userForm.getUser();
this.userBiz.findListByPage(user, userForm.getPresult()); // 将pageResult对象存入Request中,供页面分页标签显示
request.setAttribute("pageResult", userForm.getPresult());
} catch (Exception e) {
logger.error("删除用户出错", e);
request.setAttribute("msg", "系统忙!");
return mapping.getInputForward();
} return mapping.findForward("toList");
}
这样直接访问,要是可以的话就是JSP问题,不可以就要看各个action配置、方法名一大堆了,先去看看这样效果
http://你的地址[:端口/项目名]/user.do?operate=toList&(你的其他参数)