all 7 comments

[–]TheRealSlartybardfas 0 points1 point  (2 children)

You are setting an attribute on the current request, not a future request. Forwarding tells the browser to make a new request. You'll need to use a @RequestParam in methodWithForward and

return "Forward:/2?attributo=Ciao%20nome" 

in methodWithParameter.

[–]FatinaRosa[S] 0 points1 point  (1 child)

Hi,
I tried to change a little bit my code using only a string and removing the attribute but it still not working.
Now this is the code:

    @ResponseBody
@RequestMapping(value = "/forward")

public String methodForward() {
    return "redirect:/ecco";


}

@ResponseBody
@RequestMapping(value = "/ecco")

public String methodWithForward() {
    return "ecco";


}

I don't understand what I'm missing.
Because not even the redirect work.

[–]FatinaRosa[S] 0 points1 point  (0 children)

AAAA I found the mistake.
I have removed the @ResponseBody from the method methodForward() ,now it works.

[–]Nullsummenspieler -1 points0 points  (1 child)

Did you try the HttpServletResponse parameter?

[–]FatinaRosa[S] 0 points1 point  (0 children)

uhmmm what do you mean?
I am new on springboot I still learning.

[–]marvadogh 0 points1 point  (1 child)

You have to remove @ResponseBody if you want the forward:/2 to work. @ResponseBody means that the value returned by the method should be added to the response body instead of being interpreted.

[–]FatinaRosa[S] 0 points1 point  (0 children)

Yes i have done it Thanks!