SpringMvc---Ant通配符
承接一二章配置
springMVC支持Ant风格的资源地址3种匹配符
?:匹配文件名中的一个字符
如:springMVC/?a/
*:匹配文件名中的任意字符
**:匹配多层路径
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> <script type="text/javascript"> document.cookie="name=caoyc;path=/" document.cookie="age=18;path=/" // 时间可以不要,但路径(path)必须要填写, //因为JS的默认路径是当前页,如果不填,此cookie只在当前页面生效!~ </script> </head> <body> <a href="springMVC/testAntPath/ba/">testAntPath</a> </body> </html>
test.java
package com.hdxy.domian; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; /** * @author 流年拓荒者 * */ @RequestMapping("springMVC") @Controller public class Test { final public String SUCCESS="loginSuccess"; @RequestMapping("/testAntPath/?a/") public String testAntPath(){ System.out.println("testAntPatha"); return SUCCESS; } }
流年拓荒者