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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 小技巧處理div內(nèi)容溢出2. UDDI FAQs3. jsp實現(xiàn)登錄界面4. 解析原生JS getComputedStyle5. .NET SkiaSharp 生成二維碼驗證碼及指定區(qū)域截取方法實現(xiàn)6. PHP循環(huán)與分支知識點梳理7. 怎樣才能用js生成xmldom對象,并且在firefox中也實現(xiàn)xml數(shù)據(jù)島?8. PHP字符串前后字符或空格刪除方法介紹9. ASP刪除img標(biāo)簽的style屬性只保留src的正則函數(shù)10. jsp+servlet實現(xiàn)猜數(shù)字游戲
