Html SpringBoot模型属性在post请求后不可用
在通过post请求提交表单后,我尝试将一些值返回到我的webapp 控制器Html SpringBoot模型属性在post请求后不可用,html,spring-boot,thymeleaf,Html,Spring Boot,Thymeleaf,在通过post请求提交表单后,我尝试将一些值返回到我的webapp 控制器 @Controller public class testController { @ResponseBody @RequestMapping(value = "/testPage", method = RequestMethod.POST) public String downloadFile(Model model, HttpServletRequest request, HttpServletResponse r
@Controller
public class testController {
@ResponseBody
@RequestMapping(value = "/testPage", method = RequestMethod.POST)
public String downloadFile(Model model, HttpServletRequest request, HttpServletResponse response, @ModelAttribute("file") File file) {
data = file.generateData; //This method returns a string
model.addAttribute("output", fileOutput);
return "testPage";
HTML
使用胸腺素
<p th:text="${output}"></p>
标记不包含预期数据,因此为空
我错过了什么
多谢各位 带有@ResponseBody的方法是返回字符串“testPage”
如果您的页面名为testPage,则删除注释@ResponseBody删除@ResponseBody会给我以下信息:
原因:java.lang.IllegalStateException:getOutputStream()已为此响应调用
,根据我看到的代码,它不应导致此问题,据估计,您的代码编写不完整。此异常的原因是重复调用流的输出