JavaSpring控制器映射正确,但服务器返回302而不是200
我有以下控制器JavaSpring控制器映射正确,但服务器返回302而不是200,java,spring,controller,mapping,http-status-code-302,Java,Spring,Controller,Mapping,Http Status Code 302,我有以下控制器 @Controller @RequestMapping("/adwords") public class AdwordsController { @RequestMapping(method = RequestMethod.GET) public ModelAndView showForm(@ModelAttribute(Const.ADWORDS_COMMAND) AdwordsCommand adwordsCommand, BindingResult resu
@Controller
@RequestMapping("/adwords")
public class AdwordsController
{
@RequestMapping(method = RequestMethod.GET)
public ModelAndView showForm(@ModelAttribute(Const.ADWORDS_COMMAND) AdwordsCommand adwordsCommand, BindingResult result)
throws HttpSessionRequiredException
{
this.checkSessionExpired();
ModelAndView mav = new ModelAndView("adwords/adwordsRequest");
if(adwordsCommand == null)
adwordsCommand = new AdwordsCommand();
User user = this.getUser();
adwordsCommand.setEmail(user.getEmail());
mav.addObject(Const.ADWORDS_COMMAND, adwordsCommand);
return mav;
}
}
正确映射的:
13:17:49,276 INFO RequestMappingHandlerMapping:185 - Mapped "{[/adwords],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView pl.ifirma.domeny.controller.adwords.AdwordsController.showForm(java.lang.String,org.springframework.validation.BindingResult) throws org.springframework.web.HttpSessionRequiredException
但当我在浏览器中键入URL时,我会得到302代码,服务器会立即重定向到应用程序的主页面。有人能帮忙吗?为什么服务器不返回200或至少404
亚当
@评论:
这种代码的作用完全相同
@Controller
@RequestMapping("/adwords")
public class AdwordsController
{
@RequestMapping(method = RequestMethod.GET)
public ModelAndView showForm(@ModelAttribute(Const.ADWORDS_COMMAND) AdwordsCommand adwordsCommand, BindingResult result)
{
ModelAndView mav = new ModelAndView("adwords/adwordsRequest");
if(adwordsCommand == null)
adwordsCommand = new AdwordsCommand();
User user = this.getUser();
adwordsCommand.setEmail(user.getEmail());
mav.addObject(Const.ADWORDS_COMMAND, adwordsCommand);
return mav;
}
}
我想知道这种奇怪的重定向是否是由某些spring配置引起的,但是在哪里可以检查它呢?而且它是项目中唯一出现问题的地方。已解决。视图中有一个隐藏的重定向…this.checkSessionExpired()方法中有什么?它与问题100%无关-已检查。可能没有。你有日志记录吗?这是无关的,因为当我删除它时,没有任何改变。。。有趣的是,没有这种行为(重定向)的日志。这个checkSessionExpired方法实际上与“抛出HttpSessionRequiredException”和302错误有关。最好仔细检查一下这个方法!我面临着类似的问题。你在哪里找到隐藏的重定向?