[英]struts form action not being called
我正在开发使用Struts的应用程序,但我还没有完全了解Struts。
如果我在jsp页面中具有以下内容:
<form action="/accountProcess" class="" id="" method="post" enctype="multipart/form-data" autocomplete="off">
<select name="user_status_filter">
<option value="no_filter">no filter</option>
<option value="inactive">Inactive</option>
<option value="active">Active</option>
</select>
<input type="submit" value="submit"/>
</form>
在我的struts-confix.xml中:
<action-mappings>
<action path="/accountProcess"
name="UserForm"
type="x.y.UserAction"
scope="request"
parameter="dispatch"
input="pages.account"
validate="false"
roles="user">
</action>
</action-mappings>
在我的UserAction
类中:
public ActionForward getUsers(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
String requestValue = RequestUtils.getStringParameter(request, "user_status_filter");
return mapping.findForward("adminView");
}
如何获取我的表单以调用UserAction
类中的getUsers
方法? 我是否必须在表单中传递一些隐藏参数,如果是,该如何执行? 在我的表单中,我的action属性设置正确吗? 表单方法是post还是get?
找到解决方案后,我为html添加了一个隐藏字段,其中值是方法的名称
<form action="/accountProcess" class="" id="" method="post" enctype="multipart/form-data" autocomplete="off">
<html:hidden property="dispatch" value="getUsers" />
<select name="user_status_filter">
<option value="no_filter">no filter</option>
<option value="inactive">Inactive</option>
<option value="active">Active</option>
</select>
<input type="submit" value="submit"/>
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.