【发布时间】:2017-10-19 08:26:55
【问题描述】:
【问题讨论】:
-
我相信它应该放在资源文件夹中
标签: javascript css spring model-view-controller mapping
【问题讨论】:
标签: javascript css spring model-view-controller mapping
1) 创建“资源”文件夹。
2) 在你的 xml 文件中添加这个:
<mvc:resources mapping="/resources/**" location="/resources/" />
3) 在您的页面中“使用”它:
<link href="<c:url value="/resources/name_of_file.css" />" rel="stylesheet">
如果你使用 Java Config,这样的事情就可以完成:
@Configuration
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/resources/**")
.addResourceLocations("/resources/");
}
}
【讨论】: