Search code examples
javaspring-mvcstruts

Struts to spring migration


I need to handle this Struts code String navigatedFrom = mapping.getParameter(); in Spring code

public class foo extends abcAction {
    private static final String TAKEA = "HAi";
        private static final String OTHERO = "otherOptions"; 
        private static final String TAKINGA = "taking";

    @RequestMapping()
    public ModelAndView processDefault(
         ModelMap model,  HttpServletRequest request,
        HttpServletResponse response) throws ServletException,SystemException {
            String navigatedFrom =  mapping.getParameter();
            //some condtions
    }
}

How can I handle mapping.get parameter in spring mapping.getparameter()?


Solution

  • Mapping is created while processing Struts request. You have nothing to do in Spring rather than providing your own @RequestMapping.

    If you need to learn more about how to provide mapping to the request in Spring you can read Serving Web Content with Spring MVC.

    @Controller
    public class GreetingController {
    
        @RequestMapping("/greeting")
        public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) {
            model.addAttribute("name", name);
            return "greeting";
        }
    

    This code clearly shows you how to use attributes in request mapping.