0
我无法从webcontent文件夹加载JS和CSS文件。我的登录页面没有格式化,请告诉我如何加载这个我没有使用maven。 Plz找到图片。
如何从网页内容加载js和css文件spring mvc
我无法从webcontent文件夹加载JS和CSS文件。我的登录页面没有格式化,请告诉我如何加载这个我没有使用maven。 Plz找到图片。
如何从网页内容加载js和css文件spring mvc
1)创建“resources”文件夹。
2)在XML文件中添加此:
<link href="<c:url value="/resources/name_of_file.css" />" rel="stylesheet">
如果您使用Java配置,这样的事情会做的工作:
<mvc:resources mapping="/resources/**" location="/resources/" />
3)在你的页面 “使用” 它:
@Configuration
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/resources/**")
.addResourceLocations("/resources/");
}
}
我相信它应该放在资源文件夹中 –