我有以下控制器
@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?
亚当
@Comments: 这些代码的行为完全相同。
@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;
}
}
我想知道这种奇怪的重定向是否可能是由某些弹簧配置造成的,但在哪里检查呢?它只是出现问题的项目中的地方。
答案 0 :(得分:0)
解决。视图中有隐藏的重定向...