ssssssss-team/magic-api

如果使用了了Thymeleaf模板引擎,在加载后台时会报错

gantrylau opened this issue · 1 comments

magic-api: 2.1.1
jdk: 17
springboot: 2.7.15

image

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: getOutputStream() has already been called for this response] with root cause
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:572)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:189)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:108)
at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:364)
at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:190)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1406)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1150)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1089)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:965)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:529)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:623)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209)

nownew commented

有人已经提供了解决方案,添加@responsebody可屏蔽此错误消息:
@RequestMapping(value = "/config-js")
@responsebody
@Valid(requireLogin = false)