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. Django中如何使用Channels功能2. ASP.NET MVC使用Quartz.NET執(zhí)行定時(shí)任務(wù)3. CSS3+Js實(shí)現(xiàn)響應(yīng)式導(dǎo)航條4. CSS3中Transition屬性詳解以及示例分享5. ASP.NET MVC實(shí)現(xiàn)下拉框多選6. PHP中文亂碼分類及解決辦法大全7. python tkinter實(shí)現(xiàn)下載進(jìn)度條及抖音視頻去水印原理8. asp畫中畫廣告插入在每篇文章中的實(shí)現(xiàn)方法9. PHP時(shí)間相關(guān)常用函數(shù)用法示例10. 在python中修改.properties文件的操作
