使用SpringMVC时报错HTTP Status 405 - Request method 'GET' not supported

GET方法不支持。我出错的原因在于,在JSP中我希望超链接a以post方式提交,但是这里写js代码时出错。

<script type="text/javascript">
    $(function(){
        $(".delete").click(function(){
            var href = $(this).attr("href");
            $("form").attr("action",href).submit();
            //alert("ok");
            return false;
        })        
    })
</script>

js代码本身并没有错,错误的是超链接的配置。

    <form action="" method="post">
        <input type="hidden" name="_method" value="delete" />
    </form>

    <a href="emp/${emp.id }">Delete</a> 

上面是jsp代码,超链接a少了一个class="delete" 

下面这样改就对了。

 <form action="" method="post">
        <input type="hidden" name="_method" value="delete" />
    </form>

    <a class="delete" href="emp/${emp.id }">Delete</a> 

猜你喜欢

转载自www.cnblogs.com/liaoxiaolao/p/10008946.html