URL Redirection With Spring MVC

10

I want to put in my project access to a page in a views subdirectory. Type views/pessoa/criar.jsp .

How can I write a controller that accesses this page?

I'm using Spring MVC 3 and InternalResourceViewResolver .

I tried redirect and could not.

    
asked by anonymous 08.11.2014 / 23:59

2 answers

1

I'll put two methods of a controller containing the most common ways to do this.

In code it would look something like this:

@Controller
public class MainController {


    @RequestMapping(value = "/", method = RequestMethod.GET)
    public ModelAndView getdata() {
    List<String> list = getList();

        //return back to index.jsp
        ModelAndView model = new ModelAndView("index");
        model.addObject("lists", list);

        return model;
    }

    @RequestMapping(value = "/listagem", method = RequestMethod.GET)
    public String listagem() {
        return "listagem";
    }
}
    
03.07.2016 / 17:18
1

In the controller return, if everything is already set correctly - /WEB-INF/views/ as prefix and .jsp as suffix - only you return "pessoa/criar" .

    
03.07.2016 / 16:06