Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoban3.0
haoban-manage3.0
Commits
ea7f1271
Commit
ea7f1271
authored
Oct 26, 2023
by
王祖波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stream test
parent
ed8ea2c1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
8 deletions
+9
-8
ContentAIController.java
...an/manage/web/controller/content/ContentAIController.java
+3
-6
spring-servlet.xml
haoban-manage3-wx/src/main/webapp/WEB-INF/spring-servlet.xml
+1
-0
web.xml
haoban-manage3-wx/src/main/webapp/WEB-INF/web.xml
+5
-2
No files found.
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/controller/content/ContentAIController.java
View file @
ea7f1271
...
...
@@ -25,10 +25,7 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.servlet.mvc.method.annotation.SseEmitter
;
import
java.util.List
;
...
...
@@ -155,7 +152,7 @@ public class ContentAIController {
return
RestResponse
.
successResult
(
cmeTaskProcess
);
}
@RequestMapping
(
value
=
"/test"
,
produces
=
"text/event-stream;charset=UTF-8"
)
@RequestMapping
(
value
=
"/test"
,
method
=
RequestMethod
.
GET
)
public
SseEmitter
streamStockPrice
()
{
SseEmitter
emitter
=
new
SseEmitter
();
// 模拟生成实时股票价格并推送给客户端
...
...
@@ -168,7 +165,7 @@ public class ContentAIController {
// 构造股票价格的消息
String
message
=
String
.
format
(
"%.2f"
,
price
);
// 发送消息给客户端
emitter
.
send
(
SseEmitter
.
event
().
data
(
message
));
emitter
.
send
(
SseEmitter
.
event
().
data
(
message
,
MediaType
.
TEXT_PLAIN
));
// 休眠1秒钟
Thread
.
sleep
(
1000
);
}
...
...
haoban-manage3-wx/src/main/webapp/WEB-INF/spring-servlet.xml
View file @
ea7f1271
...
...
@@ -37,6 +37,7 @@
<list>
<value>
text/html;charset=UTF-8
</value>
<value>
application/x-www-form-urlencoded;charset=UTF-8
</value>
<value>
text/plain;charset=UTF-8
</value>
<!--默认是 iso-8859-1 -->
</list>
</property>
...
...
haoban-manage3-wx/src/main/webapp/WEB-INF/web.xml
View file @
ea7f1271
<?xml version="1.0" encoding="UTF-8"?>
<web-app
version=
"
2.5
"
xmlns=
"http://java.sun.com/xml/ns/javaee"
<web-app
version=
"
3.0
"
xmlns=
"http://java.sun.com/xml/ns/javaee"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_
2_5
.xsd"
>
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_
3_0
.xsd"
>
<display-name>
Archetype Created Web Application
</display-name>
<context-param>
...
...
@@ -23,6 +23,7 @@
<param-value>
/WEB-INF/spring-*.xml
</param-value>
</init-param>
<load-on-startup>
2
</load-on-startup>
<async-supported>
true
</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>
spring
</servlet-name>
...
...
@@ -39,6 +40,7 @@
<filter-mapping>
<filter-name>
encodingFilter
</filter-name>
<url-pattern>
/*
</url-pattern>
<dispatcher>
ASYNC
</dispatcher>
</filter-mapping>
<filter>
...
...
@@ -48,5 +50,6 @@
<filter-mapping>
<filter-name>
springSessionRepositoryFilter
</filter-name>
<url-pattern>
/*
</url-pattern>
<dispatcher>
ASYNC
</dispatcher>
</filter-mapping>
</web-app>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment