我正在使用一个使用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");
}
如何让我的表单在getUsers
课程中调用UserAction
方法?我是否必须在表单中传递一些隐藏参数,如果是这样,我该怎么做?在我的表单中,我的动作属性设置正确吗?表单方法会发布还是获取?
答案 0 :(得分:0)
找到了解决方案,我为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>