J'utilise des entretoises MVC. Je veux accéder à une valeur d'étiquette dans le contrôleur par les struts ActionForm. Dans le contrôleur, je peux accéder à la valeur des champs de texte par le formulaire ActionForm, car celui-ci a un champ 'name'. Mais dans label, seul 'id' est là. Donc, aidez-moi à accéder à la valeur du label par le ActionForm .Comment accéder à une valeur d'étiquette dans Struts ActionForm sur le contrôleur
jsp
<html:form action="action.do">
<label id="labelvalue">label_Value</label>
</html:form>
contrôleur
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;
}
}
struts-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>
Cela fonctionne..Merci –