[英]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.