黑马程序员技术交流社区
标题:
【成都校区】springmvc框架
[打印本页]
作者:
江山美人
时间:
2019-6-5 15:04
标题:
【成都校区】springmvc框架
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;
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2