Springboot訪問html頁面步驟解析
springboot中如果想訪問html頁面,不每訪問一個頁面就寫一個Controller,可以統(tǒng)一寫一個公共的controller方法
代碼:
(1)引入hutool工具依賴
<!-- hutool工具包--><dependency> <groupId>com.xiaoleilu</groupId> <artifactId>hutool-all</artifactId> <version>3.3.0</version></dependency>
(2)公共Controller
import com.xiaoleilu.hutool.util.StrUtil;//html訪問控制器/** * @return */@RequestMapping(value = '/view/**', method = RequestMethod.GET)public String html(HttpServletRequest request) { return StrUtil.removePrefix(request.getRequestURI(), request.getContextPath() + '/view');}
(3)訪問頁面路徑
如頁面路徑在demo下,配置文件中servlet.context-path: /test
則lhttp://localhost:8081/test/view/demo/...../XXX.html
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關文章:
1. vue style width a href動態(tài)拼接問題的解決2. Java源碼解析之接口List3. 在vue中獲取wangeditor的html和text的操作4. python mysql 字段與關鍵字沖突的解決方式5. Python用K-means聚類算法進行客戶分群的實現(xiàn)6. Java xml數(shù)據(jù)格式返回實現(xiàn)操作7. python編寫五子棋游戲8. 解決Android Studio Design界面不顯示layout控件的問題9. 使用vue-cli創(chuàng)建項目并webpack打包的操作方法10. python讀取中文路徑時出錯(2種解決方案)
