Browse Source

静态资源处理

master
453530270@qq.com 2 years ago
parent
commit
659e8728bb
  1. 10
      pom.xml
  2. 4
      src/main/resources/application.properties
  3. 27
      src/main/resources/static/index.html

10
pom.xml

@ -111,6 +111,16 @@
</dependencies>
<build>
<resources>
<!-- 打包resource里的项目配置文件 -->
<resource>
<directory>src/main/resources</directory>
<includes>
<include>static/**</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>

4
src/main/resources/application.properties

@ -3,6 +3,10 @@ server.port=9099
logging.config=classpath:logback-spring.xml
logging.path=./logs/
# 静态资源
spring.web.resources.static-locations=classpath:/static/
spring.mvc.static-path-pattern=/static/**
mybatis.mapper-locations=classpath*:/mapper/szwh/*.xml
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
# 开启调试sql语句

27
src/main/resources/static/index.html

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>EventSource测试</title>
</head>
<body>
<div>EventSource测试</div>
<ul></ul>
<script>
console.log("enventsource")
//这里填写要链接的地址
var evtSource = new EventSource('/real/psflist?page=1&limit=10');
evtSource.addEventListener('message',function(evt){
console.log(evt)
document.querySelector("ul").innerHTML+=("<li>"+JSON.parse(evt.data).message+"</li>")
})
// evtSource.onmessage=(evt)=>{
// console.log(evt.data)
// document.querySelector("ul").innerHTML+=("<li>"+JSON.parse(evt.data).message+"</li>")
// //console.log(e.data)
// }
</script>
</body>
</html>
Loading…
Cancel
Save