我在我的Spring MVC应用程序中添加了全局异常的定义,并且得到了下面的异常但我不知道什么是错误我认为我的Spring安全性问题但我不是确定任何人都可以帮助我?在Spring MVC中的全局异常defen不起作用
全局异常的定义
<!-- global exception mapping -->
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<map>
<entry key="DataAccessException" value="error" />
</map>
</property>
<property name="defaultErrorView" value="error"/>
</bean>
<!-- end global exception mapping -->
当任何异常发生在这个动作我得到一个异常 “org.springframework.web.HttpRequestMethodNotSupportedException:请求方法 'GET' 不支持”
@RequestMapping(value ="/addUser", method = RequestMethod.POST)
public String addUser(@Valid User user, BindingResult result, Model model, @RequestParam("userRole") String role) throws Exception {
if(result.hasErrors()) {
return "register";
}
String hashPassword = new PasswordHashProcessor().getHashPassword(user.getPassword());
user.setPassword(hashPassword);
daoService.addUser(user, role);
List<UserRole> users = daoService.getNotAdminUsers();
model.addAttribute("users", users);
return "users";
}
的显示日志如下
DEBUG org.springframework.security.web.util.matcher.A ntPathRequestMatcher - 检查请求匹配:'/ adduser';反对'/ admin' DEBUG org.springframework.security.web.util.matcher.AntPathRequestMatcher - 检查请求匹配:'/ adduser';反对'/ 用户' DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor - 安全对象:FilterInvocation:URL:/ addUser;属性:[hasRole('ROLE_ADMIN')] DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor - 先前已验证:org.springframew[email protected]bad860a5:Principal:org.springframework.security.core .userdetails.User @ 586034f:用户名:admin;密码保护];启用:true; AccountNonExpired:true; credentialsNonExpired:true; AccountNonLocked:true;授予权限:ROLE_ADMIN;证书:[PROTECTED];已验证:true;详细信息:org.sprin[email protected]fffdaa08:RemoteIpAddress:127.0.0.1; SessionId:52613DC126F07FDCFA50EC1B2841159F;授予权限:ROLE_ADMIN DEBUG org.springframework.security.access.vote.AffirmativeBased - 选票:org.sp[email protected]4577357d,返回:1 DEBUG org.springframework.security.web.access .intercept.FilterSecurityInterceptor - 授权成功 DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor - RunAsManager未更改身份验证对象 DEBUG org.springframework.security.web.FilterChainProxy -/addUser已到达其他过滤器链的末尾;继续处理原始链 DEBUG org.springframework.web.servlet.DispatcherServlet - 名为'mvc-dispatcher'的DispatcherServlet处理[/ Ushers/addUser]的GET请求 DEBUG org.springframework.web.servlet.mvc.method.annotation。 RequestMappingHandlerMapping - 查找路径/ addUser的处理程序方法 EBUG org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver - 解决处理程序异常[null]:org.springframework.web.HttpRequestMethodNotSupportedException:请求方法'GET'not支持 DEBUG org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver - 解决处理函数[null]中的异常:org.springframework.web.HttpRequestMethodNotSupportedException:不支持请求方法'GET' DEBUG org.springframework.web.servlet。 mvc.support.DefaultHandler ExceptionResolver - 解决处理异常[null]:org.springframework.web.HttpRequestMethodNotSupportedException:不支持请求方法'GET' WARN org.springframework.web.servlet.PageNotFound - 不支持请求方法'GET' DEBUG org.springframework。 web.servlet.DispatcherServlet - 空ModelAndView返回到名为'mvc-dispatcher'的DispatcherServlet:假设HandlerAdapter完成请求处理 DEBUG org.springframework.web.servlet.DispatcherServlet - 成功完成请求 DEBUG org.springframework.security.web.access 。的ExceptionTranslationFilter - 链处理通常 DEBUG org.springframework.security.web.context.SecurityContextPersistenceFilter - SecurityContextHolder中现在清零,作为完成