2011-07-28 43 views
0

我有一个看起来像这样的JSP表单元素..的request.getParameter返回空值在Firefox

<form method="post" action="candicreate" name="Candi_Creation" id="new_candi" onsubmit="return validateForm();"> 
    <table width="600" cellpadding="0px" cellspacing="5px"> 
    <tr> 
     <td> 
     <div class="leftDiv" align="left"><strong>Candidate First Name</strong></div> 
     </td> 
     <td> 
     <div class="rightDiv" align="right"> 
      <input required="required" form="Candi_Creation" name="cfname" type="text"/> 
     </div> 
     </td> 
    </tr> 
</table> 
</form> 

我的Servlet是这样

public class CandiCreateServlet extends HttpServlet 
{ 
    public void doPost(HttpServletRequest request, HttpServletResponse response) 
    throws IOException, ServletException 

    {  
     String fname = request.getParameter("cfname"); 
    } 
} 

这里是我的web.xml

<servlet> 
    <servlet-name>CreateCandi</servlet-name> 
    <servlet-class>com.web.formgetter.CandiCreateServlet</servlet-class> 
</servlet> 
<servlet-mapping> 
    <servlet-name>CreateCandi</servlet-name> 
    <url-pattern>/jsp/candidates/candicreate</url-pattern> 
</servlet-mapping> 

我面临的问题是,当我尝试使用firefox提交表单时,request.getParameter返回null i在servlet中。它正在与铬和ie。应该有任何浏览器配置,我应该这样做,像饼干等工作?

如有需要,我可以提供更多的说明。我非常感谢任何帮助。在此先感谢

+0

该问题可能与您的validateForm()(javascript)方法有关...... !! Firefox确实支持request.getParameter(“param”)... !! – Muse

+0

我试图删除validateForm函数仍然抛出相同的错误。我必须说我只在Firefox 4中看到这个问题。在3.xx中它的工作正常。 – n3o

+0

我知道它的工作。必须删除输入标签中的“必需”和“形式”等不必要的字段。 – n3o

回答

1

设置form="Candi_Creation"意味着输入与具有id="Candi_Creation"的表单关联,而不是任何形式碰巧是它的祖先。但是你的表单的id是一个不同的值,所以输入在你的情况下根本不与任何表单关联。