Good morning, I am trying to pass a form from a JSP to a Action. The form compiles correctly if I pass the parameters in the URL (?par=value ...) but it does not if I use submit and form value.
I think everything is set up correctly, but I must be missing something.
I've already searched other similar posts, but I couldn't find a solution.
The problem is that the form that arrives in the Action "new" method is empty.
struts.config.xml:
<form-bean name="EsempioForm" type="com.forms.EsempioForm"/>
<action name="EsempioForm" parameter="method" input="/pages/esempio.jsp" path="/esempio" scope="request" type="com.EsempioAction">
<forward ... />
</action>
esempio.jsp:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
...
<html:form action="/esempio">
<input type="hidden" id="method" name="method" value="new"/>
<html:text property="desc" disabled="true" />
<html:submit styleClass="button">record</html:submit>
</html:form>
EsempioAction.java
public ActionForward new(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
...
EsempioForm esempioForm = (esempioForm) form;
...
return mapping.findForward(...);
}
Can anyone please help me? Thank you very much for any advice.
Use <html:hidden property="method" value="new" />
instead.
EDIT:
disabled="true"
disabled fields are not posted on form submit. Make it readonly if you want to submit.