Вопрос

I have following controller

@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;
    }
}

That is mapped properly:

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

But when I type URL in browser I get 302 code and server redirects immediately to main page of application. Can anyone help? Why server does not return 200 or at least 404?

Adam

@Comments: Such code acts exactly the same.

@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;
    }
}

I wonder if this weird redirection could be caused by some spring configuration, but where to check it? And it is only place in project where problem occurs.

Это было полезно?

Решение

Solved. There was a hidden redirect in a view...

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top