Javascript和Jsp页面

| 这可能很简单,但是我不明白我在哪里做错了。我有一个包含三个链接的表单,分别是LogIn,SignUp和ForgotPassword。我使用javascript document..action使用简单的开关盒为这些链接设置了动作。 Singup和ForgotPassword分别指singup.jsp和ForgotPassword.jsp,而LogIn链接指servlet。而且我使用了web.xml文件中给出的url-pattern作为目标。当我运行它时,单击sigin会给出错误。知道出什么事了吗?
<script type=\"text/javascript\">
    function redirect(tid)
    {
      switch(tid)
      {
        case \"a\":
        {
            if(document.form.Username.value==\'\')
            {
                alert(\"Enter your username\");
                return false;
            }
            if(document.form.Password.value==\'\')
            {
                alert(\"Enter your password\");
                return false;
            }
             document.form.action=\"check\" //check is the urlpattern defined for checkUser servlet
        }
        break;
        case \"b\":
            document.form.action=\"Signup.jsp\"
            break;

        case \"c\":
            document.form.action=\"Forgotpassword.jsp\"
            break;
     }
    }
</script>
已邀请:
尝试这个:
document.forms[0].action = \'Forgotpassword.jsp\';
根据对问题的评论: 错误是此URL不支持HTTP POST方法 在URL上侦听的Servlet的
doPost()
方法没有被覆盖。显然,您正在使用ѭ3提交到仅实现ѭ4的Servlet。您需要将
doGet()
方法重命名为
doPost()
。 请注意,这与您在问题中发布的JavaScript代码无关。

要回复问题请先登录注册