當前位置:首頁 » 密碼管理 » springmvc訪問html

springmvc訪問html

發布時間: 2023-11-25 22:26:07

❶ Spring MVC 直接訪問 WEB-INF下的靜態頁面怎麼在配置文件中配置,求大神解答

注意配置的時候如下規則

1、頁面jsp(html等)的訪問必須走controller的訪問和跳轉

2、css、js等可以直接通過地址去訪問不需要走後台控制器

3、怎麼處理的,可以配置訪問限制。也就是放開對css、js等靜態資源的訪問,動態資源(.jsp用控制器去訪問),參考連接網頁鏈接

❷ springmvc 配置了跳轉到jsp頁面 怎麼實現跳轉到html頁面

先看controller:
@RequestMapping(value = "/{id}/view", method = RequestMethod.GET, proces = "text/html")
public String getPostByIdHtml( @PathVariable String id) throws IOException {
return "/resources/Post.html";
}

再看配置:
@Configuration
@EnableWebMvc
@EnableTransactionManagement
@ComponentScan({ "com.my.web.api"})
@ImportResource("classpath:db-context.xml")
public class ApiServletConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}

@Bean
public InternalResourceViewResolver internalResourceViewResolver() {
InternalResourceViewResolver internalResourceViewResolver = new InternalResourceViewResolver();
internalResourceViewResolver.setPrefix("/resources/");
internalResourceViewResolver.setSuffix("*.html");
return internalResourceViewResolver;
}
}

熱點內容
矩陣內的演算法 發布:2025-09-18 20:55:07 瀏覽:566
android網路優化 發布:2025-09-18 20:53:19 瀏覽:213
看交換機配置哪些是默認的 發布:2025-09-18 20:46:59 瀏覽:614
在釘釘上如何獲取自己的密碼 發布:2025-09-18 20:46:12 瀏覽:850
pythonifthenelse 發布:2025-09-18 20:33:19 瀏覽:908
熱血傳奇腳本怎麼做 發布:2025-09-18 20:29:06 瀏覽:606
軒逸手動經典有哪些配置 發布:2025-09-18 20:20:40 瀏覽:622
安卓手機下載軟體在哪裡設置密碼 發布:2025-09-18 20:10:08 瀏覽:605
net業務緩存框架 發布:2025-09-18 19:57:14 瀏覽:13
pythonrst 發布:2025-09-18 19:28:50 瀏覽:411