2011-06-13 72 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