Springboot訪問html頁面步驟解析
springboot中如果想訪問html頁面,不每訪問一個(gè)頁面就寫一個(gè)Controller,可以統(tǒng)一寫一個(gè)公共的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)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. JS中6個(gè)對(duì)象數(shù)組去重的方法2. Python基于requests庫爬取網(wǎng)站信息3. 資深程序員:給Python軟件開發(fā)測試的25個(gè)忠告!4. Python使用Selenium自動(dòng)進(jìn)行百度搜索的實(shí)現(xiàn)5. 一文帶你徹底理解Java序列化和反序列化6. python中文本字符處理的簡單方法記錄7. PHP利用curl發(fā)送HTTP請(qǐng)求的實(shí)例代碼8. PHP laravel實(shí)現(xiàn)導(dǎo)出PDF功能9. vscode運(yùn)行php報(bào)錯(cuò)php?not?found解決辦法10. Java commons-httpclient如果實(shí)現(xiàn)get及post請(qǐng)求

網(wǎng)公網(wǎng)安備