PLM之家PLMHome-工业软件践行者

[资料] Spring Boot的URL映射

[复制链接]

2023-5-7 15:52:20 1140 0

admin 发表于 2023-5-7 15:52:20 |阅读模式

admin 楼主

2023-5-7 15:52:20

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x

+ j5 ~. k5 d3 H, K+ H  ~* h# M
1 C! h2 ]- O( J( ]$ q5 ?4 n@RequestMapping的value属性用于匹配URL映射,value支持简单表达式:
( I+ c& {9 y' J% ]' }/ U
: m. \1 @& A& }5 H5 F@RequestMapping注解提供了method参数指定请求的Method类型,包括RequestMethod.GET、RequestMethod.POST、RequestMethod.DELETE、RequestMethod.PUT等值,分别对应HTTP请求的Method7 n; `5 h* O! `$ ?& K. j" Y! y
; r- x' v' e# ]$ w

  1. % l+ K' ]! U1 Z: z8 Q
  2. @ResTController% ?) d5 V7 m6 N+ w8 K
  3. @RequestMapping("/user")
    ; |: d! I; D5 i2 }- k
  4. public class UserRestController {& `* }3 t  T/ b/ ?' T! Y, y
  5.     @RequestMapping("/getuser/{id}")
    8 c/ L* t( }; p0 F: W. M0 O
  6.     //@PathVariable注解作用在方法参数中,用于表示参数的值来自URL路径0 H# n* Y& p0 y/ D8 E1 W
  7.     public String getUser(@PathVariable("id") Long id)
    ( G% p( R3 p9 k+ `8 v
  8.     {
    7 w; P; D( S2 W! _
  9.         User user = new User();) V8 ]1 e0 C, h8 o& s! @' ^
  10.         user.setFirstname("Donald");. q- L+ I; D& L1 o6 e
  11.         user.setLastname("Xeong");
    8 }5 f- D, V( S: s0 o3 C% M
  12.         user.setAge(40);
    / n! v. ]% ^. q3 r5 d5 Q
  13.         return  id.toString() + "\t" + user.getAge()+ "\t" + user.getFirstname() + "\t"+ user.getLastname();3 u* {/ ]* t) ~- t
  14.     }8 J& ?4 `& C/ }

  15. % f, k" B; K9 _! |0 w" K
  16.     @RequestMapping(value = "/getData",method = RequestMethod.GET)4 U) C& N4 c% J  e( @% P% V+ L6 O
  17.     public String getData() {
    & E' I/ m. q5 t( f5 ], Z
  18.         return  "requestMethod Get";
    ! A2 r! [6 U: X# J! p
  19.     }2 e. @$ Q' K+ v* R
  20.     @RequestMapping(value = "/postData",method = RequestMethod.POST)  U- n. y, N9 ]* r7 O
  21.     public String postData()7 F0 |5 ]6 n3 z4 d
  22.     {
    6 C% l" H2 O* J* s1 U
  23.         return  "RequestMethod Post";
    * e& N* G( T) [$ X
  24.     }
    ! [7 J. x. b  p" @6 v
  25. }- N4 l  P( Z/ D7 f% @- t
  26. ; A2 j3 l+ N4 K. J
复制代码

& F! c: C+ P+ \, x2 p# C
/ o( M7 y3 g+ W; E& q  z6 E% s0 n) W& a% s3 F3 o
# H1 e' s! c6 G* {8 y! [
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了