Passing table values in Dojo form to Java servlet
I am looking to pass parameter values from my dojo form to a Java servlet. I am able to connect to the servlet but I cannot extract the parameters of my form. I am trying to retrieve the value of my "appid" in my servlet. Please help!
Dojo Form (form.jsp)
<div dojoType="dijit.form.Form" id="myForm" jsId="myForm" encType="multipart/form-data"
acti开发者_运维技巧on="UpdateServlet" method="POST">
<table id="newTable">
<tbody><tr>
<td>ID:</td><td><span id="appid" title="ID"><%=app.getId()%></span></td>
</tr>
</tbody>
</table>
<button dojoType="dijit.form.Button" type="submit">
OK
</button>
</div>
UpdateServlet.java
public class UpdateServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
String appId = (String) request.getParameter("appid");
System.out.println("App id is " + appId);
//Appid is null, unable to extract value
response.sendRedirect("index.jsp");
} finally {
out.close();
}
}
}
The values of a table won't be submitted automatically when the form is submitted. You need to use some kind of form controls. In your case, I think you can add a hidden input control to do that, like below:
<input type="hidden" name="appid" value="<%=app.getId()%>">
精彩评论