2011-06-13 69 views
1

我期待将参数值从我的dojo表单传递给Java servlet。我能够连接到servlet,但我无法提取我的表单的参数。我试图在我的servlet中检索我的“appid”的值。请帮忙!将Dojo表单中的表值传递给Java servlet

道场表格(form.jsp)

<div dojoType="dijit.form.Form" id="myForm" jsId="myForm" encType="multipart/form-data" 
    action="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(); 
    } 
} 

}

回答

0

一表的值将所述表单提交时不自动提交。你需要使用某种形式的控件。在你的情况,我想你可以添加一个隐藏输入控件要做到这一点,象下面这样:

<input type="hidden" name="appid" value="<%=app.getId()%>"> 
+0

谢谢!这是我经过多次研究后才发现的。 – newtodatatables 2011-06-14 09:59:05