0

I have RequestMapping annotation placed in the class level:

@RequestMapping("view")
public class MyClas {...}

I have my method annotated with renderMapping:

@RenderMapping(params = "portletAction=myAction")
public String MyAction(RenderRequest renderRequest, RenderResponse response, @ModelAttribute Bean bean, BindingResult result,
        Model model) {...}

The problem is that after calling myAction() and returning to home page, when pressing F5, this method is called again, so I thought to implement the Post/Redirect/Get pattern, but all the solutions I found in stackoverflow where related to modifying the RequestMapping, that I can not do, since it is in class level, and the class has a lot of other methods.

Does anyone have any idea what to do in this case?

Vishal Gajera
  • 4,137
  • 5
  • 28
  • 55
Noah Martin
  • 1,708
  • 9
  • 35
  • 73
  • How do you expect it to work? You'll need to put the annotation telling Spring where to go on top of the appropriate method. You can specify something like this: `@RequestMapping(method = RequestMethod.POST, params = 'action=someAction')` You don't have to change the view name. – Christopher Schneider Apr 18 '16 at 14:04
  • Please read the question better, it works fine. I am requesting something else – Noah Martin Apr 18 '16 at 14:06
  • requestMapping is placed at the class level ;) – Noah Martin Apr 18 '16 at 14:06
  • So why can't you annotate it again? I'm missing that part. – Christopher Schneider Apr 18 '16 at 14:07
  • You mean putting "@RequestMapping(method = RequestMethod.POST, params = 'action=someAction')" in the place of renderMapping? – Noah Martin Apr 18 '16 at 14:10
  • This way there will be one requestMapping annotation at class level, and one at method level, is this normal ? – Noah Martin Apr 18 '16 at 14:13
  • You aren't limited to a single use of @RequestMapping, and value='' is optional. Your class level annotation specifies the view, whereas you can specify GET/POST requests on each method. – Christopher Schneider Apr 18 '16 at 14:16
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/109457/discussion-between-albano-vito-and-christopher-schneider). – Noah Martin Apr 18 '16 at 15:35

0 Answers0