我的任务是把已经做好的项目加上一个手机端的微网。本来他们做好的电脑端的登录页就是这样的的一个表单:
<form method="post" name="form1" action="send_message1.html">
...
<form>
测试正常。然后我把代码放到我的登录页面里,在提交表单的时候就出错了:
<form method="post" name="form1" action="send_message1.html">
...
<form>
HTTP Status 405 - Request method 'POST' not supported
这两页面的存放路径不一样的。不知是否有影响。
另外想用$.post("send_message1.html",{},function(resutlt){})这样去
请求一下,结果什么反应都没有
Controller 里面有这样一个方法: @RequestMapping("/send_message1")
 public String Send_Message1(HttpServletRequest request,HttpSession session) throws  Exception{
    System.out.println("进入");
    ...
}spring mvc

解决方案 »

  1.   

    改成get的报404了。
    问题是电脑端的登录页也是用post啊。为什么那就不报错。。
    我的页面的form也是复制过来的。怎么就错了
      

  2.   

    把html页面改成jsp或一个controller
      

  3.   

    send_message1.html 并不是一个html页面@RequestMapping("/send_message1")
    public String Send_Message1(...){
        ...
    }
      

  4.   

    电脑端的页面是在WEB-INF目录下的。我的页面为了方便测试直接放在WebContent下了。是这里造成的原因吗。。 同样的代码放在不同的文件里就出错了。我想到的只有路径原因了
      

  5.   

    是不是还需要配置什么。 感觉spring mvc什么都需要配置 超级麻烦。
      

  6.   

    你配置注解后,要在配置文件中配置视图解析器给你提交的地址加上前后缀,还有,即然你注解中没带后缀,那你的表单也就不要代了,@RequestMapping("/send_message1")好像还可以指定一个method
      

  7.   


    <property name="prefix" value="WEB-INF/page/"></property>
    <property name="suffix" value=".jsp"></property>
    配置文件里有这个配置了。不过好像不关这个的事。
    WEB-INF/page/ 这目录下是别人写的电脑端的页面。他的页面可以正常进入到Controller。一切正常。我的页面是放在WebContent/mobile/page目录下。<mvc:resources location="mobile/" mapping="/mobile/**"/>
    在我的页面里提交这个表单的话就会出错。他的不会<form method="post" name="form1" action="send_message1.html">
    ...
    <form>
    强烈感觉是路劲问题。 但不知道具体在哪里 ,改怎么解决