我有以下控制器
@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;
}
}
我想知道这种奇怪的重定向是否可能是由一些弹簧配置引起的,但是在哪里检查呢?它只是出现问题的项目中的地方。