我在jsp中有複選框。我想根據從數據庫檢索到的值來設置它的值。從數據庫中檢索值。如何從Action類設置爲Action Form和JSP?
我已經檢索了操作類中的值,但我無法將此值從操作類設置爲jsp頁面。
我是新手。任何人都可以請告訴如何做到這一點。
JSP:
<html:form action="faxDownloadSettings">
<html:hidden property="checkMe"/>
<input type=checkbox name="pdf" property="checkMe" checked="checked"> <bean:message key="com.console.asPDF"/>
<console:button name="save" script="save();">
<console:label><bean:message key="com.console.save"/></console:label>
</console:button>
操作形式:
public class FaxDownloadSettingsForm extends ActionForm {
private boolean checkMe;
public void setCheckMe(boolean checkMe){
this.checkMe = checkMe;
}
public boolean getCheckMe(){
return checkMe;
}
}
Action類:
public class FaxDownloadSettingsAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response)
throws Exception {
FaxDownloadSettingsForm form = (FaxDownloadSettingsForm) actionForm;
boolean isFaxtopdf = enumResponse.getFaxtopdf();
request.setAttribute("checkFax", isFaxtopdf);
form.setCheckMe(true); //It also not works
}
return mapping.findForward("success");
}
你爲什麼不能初始化'ActionForm'正常嗎? – 2014-12-09 17:11:09