jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<body>
<h2>Hello World!</h2>
<!-- rest风格 -->
<a href="users/add5/1/zhangsan">添加5</a>
<!-- ant风格-->
<a href="users/aa/add6">添加6</a>
</body>
</html>
java
package com.test.controller;
import com.test.pojo.Users;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
@Controller
@RequestMapping("/users")
public class UsersController {
//方式4
@RequestMapping("/add5/{id}/{name}")
public String add5(@PathVariable(value="id") int id,@PathVariable(value="name") String name)
{
System.out.println(id);
System.out.println(name);
return "success";
}
//方法5
/*
**:匹配任意路径
* :匹配任意字符 0个或任意个
?:匹配一个任意字符
*/
@RequestMapping("/**/?dd6")
public String add6()
{
return "success";
}
}
文章来源地址https://www.toymoban.com/news/detail-705147.html
文章来源:https://www.toymoban.com/news/detail-705147.html
到了这里,关于javaee springMVC Rest风格和Ant风格的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!