springboot和jsp,以及引入jquery
包:
src:
main:
java:
resources:
static:
templates:
test:
2.在static导入jquery源文件,在templates写入jsp文件
3.配置文件:
server.port=8888
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.jsp
4.mvc自动略掉jquery,交个tomcat处理:
@Configuration
public class MyMvcConfig extends WebMvcConfigurationSupport {
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
super.addResourceHandlers(registry);
}
}
5.jquery导入jsp:
<script type="text/javascript" src="../static/jquery.js">
</script>
<script>
// $(function () {
// alert("ccccccccccc")
// })
$(document).ready(function () {
alert("hhhhhhhhh")
})
alert("ggggggg")
</script>