package com.itheima.controller;
import com.itheima.domain.user;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.support.BindingAwareModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
//@RequestMapping("/user")
public class UserController {
@RequestMapping("/quick")
public String quick() {
System.out.println("quick");
return "html.jsp";
}
@RequestMapping(value = "/quick1",produces = "application/json;charset=utf-8")
public String quick1(Model model1,String username) {
model1.addAttribute("username", username);
return "html.jsp";
}
@RequestMapping("/quick2")
public ModelAndView quick2(ModelAndView modelAndView) {
modelAndView.setViewName("html.jsp");
modelAndView.addObject("username","itheima");
return modelAndView;
}
@RequestMapping("/quick3")
@ResponseBody
public user quick3() {
user user = new user();
user.setName("yy");
user.setAge(18);
return user;
}
}
|
|