Я работаю с AngularJs, Bootstrap в передней части и Java-Spring MVC -Spring security-Hibernate в бэкэнд. 1. Итак, я создал пользователя 2. Я вхожу в систему 3. Я заполняю форму профилей, и когда у меня есть сбой, у меня ошибка 405.Почему я получаю сообщение не разрешено (405)?
Я не понимаю, почему я получаю ошибку 405, когда я делаю запрос на отправку.
Это моя просьба отправить из AngularJS службы:
save : function(user) {
return $http({
method: 'POST',
url: 'http://localhost:8080/app-web/user/profil/'+user.id+'/create',
data:user
})
У меня есть http://localhost:8080/app-web/user/profil/49/create failed with status 405
Вот мой Spring Security конфигурационный файл сниппет:
<sec:http realm="Protected API" use-expressions="true" auto-config="false" create-session="stateless" entry-point-ref="unauthorizedEntryPoint" authentication-manager-ref="authenticationManager">
<sec:custom-filter ref="authenticationTokenProcessingFilter" position="FORM_LOGIN_FILTER" />
<sec:intercept-url pattern="/login" access="permitAll" />
<sec:intercept-url pattern="/user/**" access="permitAll" />
<sec:intercept-url pattern="/user/profil/**" access="permitAll" />
<sec:intercept-url pattern="/user/**" access="permitAll" />
</sec:http>
Мой контроллер:
@RequestMapping(value="/user")
public class UserProfileController {
@RequestMapping(value="/profil/{userid}/create", method= RequestMethod.POST)
@ResponseBody
public String createProfil(@RequestBody User user){
// my logic
return "OK";
}
}
Весенний журнал:
21:40:40.617 [http-bio-8080-exec-4] DEBUG o.s.s.w.a.i.FilterSecurityInterceptor - Authorization successful
21:40:40.617 [http-bio-8080-exec-4] DEBUG o.s.s.w.a.i.FilterSecurityInterceptor - RunAsManager did not change Authentication object
21:40:40.617 [http-bio-8080-exec-4] DEBUG o.s.security.web.FilterChainProxy - /user/profil/49/create reached end of additional filter chain; proceeding with original chain
21:40:40.617 [http-bio-8080-exec-4] INFO c.d.j.web.filters.SimpleCORSFilter - Request ====> 127.0.0.1 ===> [email protected]
21:40:40.623 [http-bio-8080-exec-4] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'app' processing POST request for [/app-web/user/profil/49/create]
21:40:40.625 [http-bio-8080-exec-4] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /user/profil/49/create
21:40:40.627 [http-bio-8080-exec-4] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/user/profil/49/create]
21:40:40.627 [http-bio-8080-exec-4] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - Matching patterns for request [/user/profil/49/create] are [/**]
21:40:40.627 [http-bio-8080-exec-4] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - URI Template variables for request [/user/profil/49/create] are {}
21:40:40.628 [http-bio-8080-exec-4] DEBUG o.s.w.s.h.SimpleUrlHandlerMapping - Mapping [/user/profil/49/create] to HandlerExecutionChain with handler [org.[email protected]663ef60] and 1 interceptor
21:40:40.629 [http-bio-8080-exec-4] DEBUG o.s.w.s.m.a.ResponseStatusExceptionResolver - Resolving exception from handler [org.[email protected]663ef60]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported
21:40:40.630 [http-bio-8080-exec-4] DEBUG o.s.w.s.m.s.DefaultHandlerExceptionResolver - Resolving exception from handler [org.[email protected]663ef60]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported
21:40:40.630 [http-bio-8080-exec-4] WARN o.s.web.servlet.PageNotFound - Request method 'POST' not supported
21:40:40.630 [http-bio-8080-exec-4] DEBUG o.s.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'app': assuming HandlerAdapter completed request handling
21:40:40.630 [http-bio-8080-exec-4] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request
21:40:40.630 [http-bio-8080-exec-4] DEBUG o.s.s.w.a.ExceptionTranslationFilter - Chain processed normally
21:40:40.631 [http-bio-8080-exec-4] DEBUG o.s.s.w.c.SecurityContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed
Вы проверили какие-либо из многочисленных других вопросов, касающихся Spring MVC и ошибки 405? –
Да, я проверил другие сообщения, но никто не мог мне помочь. – Pracede
Посмотрите на свой журнал, он дает ключ. –