Spring MVC獲取查詢參數(shù)及路徑參數(shù)代碼實例
更新時間:2020年02月13日 14:15:28 作者:Esrevinud的筆記
這篇文章主要介紹了Spring MVC獲取查詢參數(shù)及路徑參數(shù)代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
這篇文章主要介紹了Spring MVC獲取查詢參數(shù)及路徑參數(shù)代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
Jsp頁面 query.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %> <html> <head> <title>Title</title> </head> <body> <h1>您輸入的id是 ${id}</h1> </body> </html>
@RequestParm獲取查詢參數(shù)
@Controller @RequestMapping("/test") public class TestController { @RequestMapping(value = "/user", method = RequestMethod.GET) public String user(@RequestParam("id") int id, Map<String, Integer> map) { map.put("id", id); return "query"; } }
以上可訪問.../test/user?id=10測試
@PathVariable獲取路徑參數(shù)
@Controller public class TestController { @RequestMapping(value = "/user/{id}", method = RequestMethod.GET) public String user(@PathVariable("id") int id, Map<String, Integer> map) { map.put("id", id); return "query"; } }
以上可訪問.../user/10測試
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- SpringMVC自定義參數(shù)綁定實現(xiàn)詳解
- SpringBoot中通過實現(xiàn)WebMvcConfigurer參數(shù)校驗的方法示例
- Spring MVC請求參數(shù)與響應結(jié)果全局加密和解密詳解
- 解決SpringMVC接收不到ajaxPOST參數(shù)的問題
- 快速解決SpringMVC @RequestBody 用map接收請求參數(shù)的問題
- 解決SpringMVC Controller 接收頁面?zhèn)鬟f的中文參數(shù)出現(xiàn)亂碼的問題
- springmvc 傳遞和接收數(shù)組參數(shù)的實例
- axios發(fā)送post請求springMVC接收不到參數(shù)的解決方法
- 聊聊springmvc中controller的方法的參數(shù)注解方式
相關文章
Mybatis使用XML實現(xiàn)動態(tài)sql的示例代碼
當編寫 MyBatis 中復雜動態(tài) SQL 語句時,使用 XML 格式是一種非常靈活的方式,本文主要為大家詳細介紹了Mybatis使用XML實現(xiàn)動態(tài)sql的具體方法,需要的可以參考下2023-12-12如何通過idea實現(xiàn)springboot集成mybatis
這篇文章主要介紹了如何通過idea實現(xiàn)springboot集成mybatis,使用springboot 集成 mybatis后,通過http請求接口,使得通過http請求可以直接操作數(shù)據(jù)庫,本文結(jié)合實例代碼給大家介紹的非常詳細,需要的朋友可以參考下2023-09-09