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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 讀大數(shù)據(jù)量的XML文件的讀取問題2. 概述IE和SQL2k開發(fā)一個(gè)XML聊天程序3. CSS可以做的幾個(gè)令你嘆為觀止的實(shí)例分享4. JSP之表單提交get和post的區(qū)別詳解及實(shí)例5. jsp+servlet實(shí)現(xiàn)猜數(shù)字游戲6. asp知識整理筆記4(問答模式)7. 低版本IE正常運(yùn)行HTML5+CSS3網(wǎng)站的3種解決方案8. JSP+Servlet實(shí)現(xiàn)文件上傳到服務(wù)器功能9. jsp文件下載功能實(shí)現(xiàn)代碼10. javascript xml xsl取值及數(shù)據(jù)修改第1/2頁
