<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                前后端交互時常用的注解總結如下。 [TOC] # 1. 用于映射地址的注解 **1. `org.springframework.web.bind.annotation.RequestMapping`** ```java //作用:映射請求地址 public @interface RequestMapping { //name、value、path作用相同,都是請求地址 String name() default ""; @AliasFor("path") String[] value() default {}; @AliasFor("value") String[] path() default {}; //請求方式 RequestMethod[] method() default {}; //前端傳遞過來的數據,有以下幾種情況 // params = "username" 則請求地址必須攜帶username參數 // params = "!username" 則請求地址必須不能攜帶username參數 // params = "username=zhangsan" 則請求地址必須攜帶username=zhangsan的參數 // params = "username=!zhangsan" 則請求地址必須不能攜帶username=zhangsan的參數 String[] params() default {}; //請求頭,有以下幾種情況 // headers = "username" 則請求地址必須攜帶username參數 // headers = "!username" 則請求地址必須不能攜帶username參數 // headers = "username=zhangsan" 則請求地址必須攜帶username=zhangsan的參數 // headers = "username=!zhangsan" 則請求地址必須不能攜帶username=zhangsan的參數 String[] headers() default {}; //請求的數據類型 String[] consumes() default {}; //響應的數據類型 String[] produces() default {}; } ``` **2. `org.springframework.web.bind.annotation.DeleteMapping`** ```java //等價于@RequestMapping(method = {RequestMethod.DELETE}) @RequestMapping( method = {RequestMethod.DELETE} ) public @interface DeleteMapping { ... } ``` **3. `org.springframework.web.bind.annotation.GetMapping`** ```java //等價于@RequestMapping(method = {RequestMethod.GET}) @RequestMapping( method = {RequestMethod.GET} ) public @interface GetMapping{ ... } ``` **4. `org.springframework.web.bind.annotation.PostMapping`** ```java //等價于@RequestMapping(method = {RequestMethod.POST}) @RequestMapping( method = {RequestMethod.POST} ) public @interface PostMapping{ ... } ``` **5. `org.springframework.web.bind.annotation.PutMapping`** ```java //等價于@RequestMapping(method = {RequestMethod.PUT}) @RequestMapping( method = {RequestMethod.PUT} ) public @interface PutMapping{ ... } ``` <br/> # 2. 用于接收前端數據的注解 **1. `org.springframework.web.bind.annotation.RequestParam`** ```java public @interface RequestParam { //value、name作用相同,都是用來接收前端傳遞過來的數據 @AliasFor("name") String value() default ""; @AliasFor("value") String name() default ""; //如果為true,則value指定的參數名必須傳遞 boolean required() default true; String defaultValue() default "\n\t\t\n\t\t\n\ue000\ue001\ue002\n\t\t\t\t\n"; } ``` **2. `org.springframework.web.bind.annotation.RequestBody`** ```java //前端傳遞數據必須為json字符串 //只能用在請求方式為POST的方法中 public @interface RequestBody { //如果為true則前端必須傳遞響應的參數,但是好像沒用,忽略即可 boolean required() default true; } ``` **3. `org.springframework.web.bind.annotation.PathVariable`** ```java //用于RESTful風格請求的url地址 public @interface PathVariable { @AliasFor("name") String value() default ""; @AliasFor("value") String name() default ""; boolean required() default true; } ``` **4. `org.springframework.web.bind.annotation.RequestPart `** ```java //用于請求數據類型為multipart/form-data的方法上 public @interface RequestPart { @AliasFor("name") String value() default ""; @AliasFor("value") String name() default ""; boolean required() default true; } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看