私はstruts MVCを使用しています。私は、ストラットのActionFormによってコントローラ内のラベル値にアクセスしたいと思います。コントローラでは、ActionFormでテキストフィールド値の値にアクセスできます。なぜなら、 'name'フィールドを持っているからです。しかし、ラベルには 'id'だけしかありません。ActionFormによってコントローラにラベル値にアクセスするのを助けてください。コントローラのStruts ActionFormでラベル値にアクセスする方法
JSP
<html:form action="action.do">
<label id="labelvalue">label_Value</label>
</html:form>
コントローラ
public ActionForward defaultMethod(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
try{
StrutsActionForm actform;
actform= (StrutsActionForm) form;
String labelvalue=actform.getLabelValue();//now it shows null.I want to get the value from the label field
return "success";
}catch(Exception e){
return null;
}
}
StrutsActionForm
publi class StrutsActionForm extends ActionForm{
private String labelvalue;
public String getLabelValue() {
return labelvalue;
}
public void setLabelValue(String labelvalue) {
this.labelvalue= labelvalue;
}
}
支柱-config.xmlの
<form-beans>
<form-bean name="strutsActionForm" type="com.StrutsActionForm"></form-bean>
</form-beans>
<action-mappings>
<action path="/action" name="strutsActionForm" input="/index.jsp"
type="com.Controller">
<forward name="success" path="/successWindow" />
</action>
</action-mappings>
それは動作します..ありがとう –