简体   繁体   English

405不允许使用方法http方法:spring-security中不支持请求方法'GET'

[英]405 Method Not Allowed http method being used: Request method 'GET' not supported` in spring-security

I have the file spring-security.xml configured as follow: 我将文件spring-security.xml配置如下:

    <http auto-config="true">
    <intercept-url pattern="/welcome*" access="ROLE_ADMIN" />
    <form-login login-page="/login" default-target-url="/welcome" 
        authentication-failure-url="/loginfailed" />
    <logout logout-success-url="/logout" />
</http>

dispatch-servlet.xml as follow dispatch-servlet.xml如下

 <context:component-scan base-package="springmvc.web" />
<mvc:resources mapping="/resources/**"  location="/resources/" />

<mvc:default-servlet-handler />

<!-- Declare a view resolver -->
<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver"
    p:prefix="/WEB-INF/views/" p:suffix=".jsp" />

so accessing through the URL ../myapp/welcome or ../myapp/login I get an 405, and there is a login.jsp under /WEB-INF/view/login.jsp 所以通过URL ../myapp/welcome或../myapp/login访问时,我得到一个405,并且在/WEB-INF/view/login.jsp下有一个login.jsp

Thanks 谢谢

Here /login and /welcome are expected to be controller(@Controller annotated classes) methods annotated with appropriate @RequestMapping . 在这里/login/welcome应该是使用适当的@RequestMapping注释的controller(@Controller注释类)方法。

One workaround, if all your controller does is to return the view name may be to do the following: 一种解决方法是,如果您的控制器要做的就是返回视图名称,则可以执行以下操作:

<mvc:view-controller path="/login" view-name="login"/>
<mvc:view-controller path="/welcome" view-name="welcome"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 405不允许使用方法http方法:使用Spring MVC时不支持请求方法&#39;GET&#39;。 - 405 Method Not Allowed http method being used: Request method 'GET' not supported` while using Spring MVC? spring-security:HTTP状态405-不支持请求方法“ POST” - spring-security:HTTP Status 405 - Request method 'POST' not supported 405不允许使用方法:不支持请求方法“ GET” - 405 Method Not Allowed :Request method 'GET' not supported Spring Security过滤器,HTTP状态405-不支持请求方法“ POST” - Spring Security filter, HTTP Status 405 - Request method 'POST' not supported spring security 4.0.1 - HTTP状态405 - 不支持请求方法“POST” - spring security 4.0.1 - HTTP Status 405 - Request method 'POST' not supported HTTP状态405 - 不支持请求方法&#39;POST&#39; - Spring Security - HTTP Status 405 - Request method 'POST' not supported - Spring Security "Spring Security - 不支持 405 请求方法“POST”" - Spring Security - 405 Request Method 'POST' Not Supported Spring 4的Thymeleaf表单:Etat HTTP 405-请求方法&#39;GET&#39;不支持 - Thymeleaf form with spring 4: Etat HTTP 405 - Request method 'GET' not supported HTTP状态405 - 不支持请求方法“GET” - HTTP Status 405 - Request method 'GET' not supported 405 - 不支持请求方法“POST” Spring MVC + Spring 安全 - 405 - Request method 'POST' not supported Spring MVC + Spring Security
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM