package com.liuawei.web.controller.Response;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.liuawei.model.Gril;

/*
 * 跳转到对于的视图页面
 */
@Controller
@RequestMapping(value="views/**")
public class ViewsController {
	
	/*
	 * 跳转到对应的视图
	 */
	@RequestMapping(value="html",method=RequestMethod.GET)
	public String demo1(Model model){
		model.addAttribute("name", "赵娟");
		model.addAttribute("age", 16);
		System.out.println(model.toString());
		return "views/html";
	}
	
	/*
	 * 文件路径名---请求地址一致
	 */
	@RequestMapping(value="viewName",method=RequestMethod.GET)
	public void demo2(Model model){
		model.addAttribute("name", "赵娟");
		model.addAttribute("age", 16);
		System.out.println(model.toString());
	}
	
	/*
	 * 匹配路径参数
	 */
	@RequestMapping(value="pathVariables/{name}/{age}", method=RequestMethod.GET)
	public String pathVars(@PathVariable String name, @PathVariable int age) {
		return "views/html";
	}
	
	/*
	 * 参数匹配JavaBean
	 */
	@RequestMapping(value="dataBinding/{name}/{age}", method=RequestMethod.GET)
	public String dataBinding(Gril gril, Model model) {
		System.out.println(gril.toString());
		return "views/dataBinding";
	}


}
