Java 不支持Spring Security 4@PreAuthorize Http 405 POST

Java 不支持Spring Security 4@PreAuthorize Http 405 POST,java,spring,spring-security,Java,Spring,Spring Security,我对spring-security@PreAuthorize注释有问题,我在我的Dao接口中对该方法进行了如下注释: public interface SecurityDao { public List<Security> listAll(); public List<Security> getUserbyId(String id); @PreAuthorize("hasRole('ROLE_4')") public void addUse

我对spring-security@PreAuthorize注释有问题,我在我的Dao接口中对该方法进行了如下注释:

public interface SecurityDao {
    public List<Security> listAll();
    public List<Security> getUserbyId(String id);
    @PreAuthorize("hasRole('ROLE_4')")
    public void addUser(String username, byte securityLevel);
    @PreAuthorize("hasRole('ROLE_4')")
    public void deleteUser(String username);
    @PreAuthorize("hasRole('ROLE_4')")
    public void updateUser(String username, byte securityLevel);
}
我的controllerrequestmethod是POST,用于处理来自提交的成功消息(正如我上面所说的,这很好)

我见过类似的问题,但没有答案,以前有人经历过这种行为吗?这是预期的吗

提前感谢,


Adam

尝试在实现类上放置注释。可能您正在转发页面以管理错误。当您使用forward时,请求是相同的,在本例中是POST,但您的错误页面不支持POST only GET。
 @RequestMapping(value="/EditUser", method=RequestMethod.POST)
        public ModelAndView editUser(@RequestParam
                String username, byte securityLevel, ModelMap map, boolean isNewUser) {

            if (isNewUser){
                SecDao.addUser(username, securityLevel);
            }else{
                SecDao.updateUser(username, securityLevel);
            }
                    ModelAndView model = new ModelAndView("userManagement");
                    String applicationVersion = applicationInformation.get("version");
                    model.addObject("version", applicationVersion);
                    List<Security> listSec = SecDao.listAll();
                    model.addObject("user", listSec);


                return model;


        }