首页 > 代码库 > SpringMVC的view

SpringMVC的view

@RequestMapping("/person/{name}/{age}")
@ResponseBody //如果只是输出内容,则要加上这个,否则就会要hello.jsp
public String toPerson(@PathVariable String name,@PathVariable double age){
System.out.println(name+" "+age);
return "hello";
}

@RequestMapping(value = "http://www.mamicode.com/viewCar")
public String viewCar(Model model)
{
Car car = new Car();
car.setBrand("auto");
car.setPrice(100.00);
model.addAttribute(car);
return "/index/index"; //将car输出到model中,会输出index/index页面上
}

SpringMVC的view