Swagger2的使用和網頁測試以及Captcha驗證碼和文件下載上傳 +解決跨域問題


鏈接

意義

寫好的接口可以直接測了 不需要postman中自己輸入

環境

<dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger2</artifactId>
      <version>2.6.1</version>
</dependency>
<dependency>
     <groupId>io.springfox</groupId>
     <artifactId>springfox-swagger-ui</artifactId>
     <version>2.6.1</version>
</dependency>

springboot配置




接口

注解

controll改變

簡單的改變

入參改變

工具使用

地址

輸入 http://localhost:8080/swagger-ui.html#/

token處理

沒有Authorize的按鈕

Captcha驗證碼實現

地址

注意

1、照片是后台發的(不需要授權) 發的是照片+uuid 現在使用后台的驗證 (可以配置驗證碼的模式)

文件下載

文件上傳

同下載

wagger-bootstrap-ui 的使用

wagger-bootstrap-ui 的介紹

跨域問題

報錯


Access to XMLHttpRequest at 'http://192.168.1.104:8000/api/user/token' from origin 'http://localhost:8080' has been blocked by CORS policy: 
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

springboot解決方案

接口增加描述

BEAN 實體

接口 實體



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM