**
关于通用页面跳转功能
常规:一个请求对应一个方法
需求:一个方法实现多个url请求的的跳转
想法:能否动态接受url中的参数
restFul风格01
/**
* 1.参数之间用/分割
* 2.参数使用{}形式包裹
* 3.@PathVariable实现数据的转换
*@RequestMapping("/page/{moduleName}")
*/
package com.jt.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class IndexController {
@RequestMapping("/page/{moduleName}")
public String module(@PathVariable String moduleName) {
return moduleName;
}
}
restFul风格02
/**
* restFul风格02的实现:
* 利用请求的类型指定业务功能
* type="GET" 查询业务
* type="POST" 新增业务
* type="PUT" 更新业务
* type="DELETE" 删除业务
*@RequestMapping(value = "/page/{moduleName}",method =RequestMethod.Get)
*/
package com.jt.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class IndexController {
@RequestMapping(value = "/page/{moduleName}",method =RequestMethod.Get)
public String module(@PathVariable String moduleName) {
return moduleName;
}
}
**总结:**如果要动态获取url中的参数,需要用restFul实现