日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

SpringBoot 路径访问控制

發布時間:2024/4/13 javascript 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SpringBoot 路径访问控制 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;@RestController public class HelloController {@RequestMapping("/echo")public String echo(String msg) {return "【ECHO】" + msg;}@RequestMapping("/")public String home() {return "www.baidu.com";} }http://localhost:8080/echo?msg=hello package com.microboot.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.RestController;@RestController public class HelloController {@RequestMapping(value="/echo/{message}",method=RequestMethod.GET)public String echo(@PathVariable("message")String msg) {return "【ECHO】" + msg;}@RequestMapping("/")public String home() {return "www.baidu.com";} }http://localhost:8080/echo/hello <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>bootfirst</groupId><artifactId>bootfirst</artifactId><version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.5.12.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><java.version>1.8</java.version><thymeleaf.version>3.0.9.RELEASE</thymeleaf.version><thymeleaf-layout-dialect.version>2.3.0</thymeleaf-layout-dialect.version><!-- 布局功能的支持程序 thymeleaf3主程序 layout2以上版本 --><!-- thymeleaf2 layout1 --><thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version></properties> <dependencies><dependency><!-- 引入web模塊 --><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId></dependency><!-- 熱部署方法1spring boot devtools 依賴包. --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><optional>true</optional><scope>true</scope></dependency><!-- 熱部署方法2--><dependency><groupId>org.springframework</groupId><artifactId>springloaded</artifactId></dependency></dependencies><!-- 這個插件,可以將應用打包成一個可執行的jar包 --><build><finalName>bootfirst</finalName><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project> package com.microboot.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.RestController;@RestController public class HelloController {@RequestMapping(value="/echo/{message}",method=RequestMethod.GET)public String echo(@PathVariable("message")String msg) {return "【ECHO】" + msg;}@RequestMapping("/mul")public Object mul(int num) {return num * 2;}@RequestMapping("/")public String home() {return "www.baidu.com";} }http://localhost:8080/mul?num=20 package com.microboot.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.RestController;@RestController public class HelloController {@RequestMapping(value="/echo/{message}",method=RequestMethod.GET)public String echo(@PathVariable("message")String msg) {return "【ECHO】" + msg;}@RequestMapping("/mul")public Object mul(int num) {return num * 5;}@RequestMapping("/")public String home() {return "www.baidu.com";} }

?

總結

以上是生活随笔為你收集整理的SpringBoot 路径访问控制的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。