jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<body>
<h2>Hello World!</h2>
<!-- rest風(fēng)格 -->
<a href="users/add5/1/zhangsan">添加5</a>
<!-- ant風(fēng)格-->
<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個(gè)或任意個(gè)
?:匹配一個(gè)任意字符
*/
@RequestMapping("/**/?dd6")
public String add6()
{
return "success";
}
}
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-705147.html
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-705147.html
到了這里,關(guān)于javaee springMVC Rest風(fēng)格和Ant風(fēng)格的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!