SpringMVC---@PathVariable

承接一二章

 

支持占位符

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello World</title>


  
  <body>
    <a href="springMVC/pathVariable/1">pathVariable</a>
    
  </body>
</html>

test.java

package com.hdxy.domian;

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

/**
 * @author 流年拓荒者
 * 
 *
 */
@RequestMapping("springMVC")
@Controller
public class Test {
   final public String SUCCESS="loginSuccess";
   /*
    * */
   @RequestMapping("/pathVariable/{id}")
   public String pathVariable(@PathVariable("id")Integer id){
       System.out.println("pathVariable"+id);
       return SUCCESS;
   }
   
   
}

 

posted @ 2017-12-02 19:34  流年拓荒者  阅读(146)  评论(0编辑  收藏  举报
   
在博客右侧,浮出一个微博浮动框