- package com.boventech.learning.controller;
-
- import java.util.HashMap;
- import java.util.Map;
-
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.servlet.ModelAndView;
-
- import com.boventech.learning.entity.User;
-
- @Controller
- @RequestMapping("/MVCReturn")
- public class SpringMVCReturnController {
-
- @RequestMapping(value="/index1",method=RequestMethod.GET)
- public ModelAndView index(){
- ModelAndView modelAndView = new ModelAndView("/user/index");
- modelAndView.addObject("name", "xxx");
- return modelAndView;
- }
-
-
- @RequestMapping(value="/index2",method=RequestMethod.GET)
- public ModelAndView index2(){
- ModelAndView modelAndView = new ModelAndView();
- modelAndView.addObject("name", "xxx");
- modelAndView.setViewName("/user/index");
- return modelAndView;
- }
-
-
-
- @RequestMapping(value="/index3",method=RequestMethod.GET)
- public Map<String, String> index3(){
- Map<String, String> map = new HashMap<String, String>();
- map.put("1", "1");
-
- return map;
- }
-
-
-
-
- @RequestMapping(value="/index4",method = RequestMethod.GET)
- public String index(Model model) {
- String retVal = "user/index";
- User user = new User();
- user.setName("XXX");
- model.addAttribute("user", user);
- return retVal;
- }
-
-
- @RequestMapping(value = "/valid", method = RequestMethod.GET)
- @ResponseBody
- public String valid(@RequestParam(value = "userId", required = false) Integer userId,
- @RequestParam(value = "name") String name) {
- return String.valueOf(true);
- }
-
-
-
- @RequestMapping(method=RequestMethod.GET)
- public void index5(){
- ModelAndView modelAndView = new ModelAndView();
- modelAndView.addObject("xxx", "xxx");
- }
-
-
-
-
- }