如何解决SpringBoot-我试图将参数从视图传递到控制器,并且试图在另一个视图中显示结果,但是它不起作用
我试图在home.jsp中构建一个表单
<form method="POST" action="uploadfile" th:action="@{/uploadfile}" enctype="multipart/form-data">
<input type="file" name="file" accept=".xls"/> <br/><br/>
<label for="fname">order address:</label>
<input type="text" id="address" name="address" size="50">
<label for="lname">order account:</label>
<input type="text" id="account" name="account" size="50"><br/><br/>
<label for="lname">:</label>
<button type="submit">summit/button>
</form>
result.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="/node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="/node_modules/bootstrap/dist/css/style.css" rel="stylesheet">
<meta charset="UTF-8">
<title>result</title>
</head>
<body>
<div th:if="${message}">
<h2 th:text="${message}"/></div>
<form action="/download" method="post">
<text name="filename" type="text" value="${downloadfile}"/><br/>
<input type="submit" value="download XML" />
</form>
</body>
</html>
这是我的控制器
@PostMapping("/uploadfile")
public ModelAndView uploadFile(@RequestParam("file") MultipartFile file,@RequestParam(name="address",required = false) String myaddress,@RequestParam(name="account",required = false) String myaccount
)
{
....................
..................
ModelAndView model = new ModelAndView("result"); //tried to return this parameters
model.addObject("excecontentslist",tempExcelcontentList); //tried to show the contents of Excel
model.addObject("message",consequencemsg);//tried to show the message we have
model.addObject("downloadfile",xmlfilename); //tried to show the xml which is gonna download
return model;//got 404 error when all things has been done
}
我要做的就是将结果模型的数据发送到result.jsp以显示那里的数据,但是它不起作用,只是显示了404错误,知道吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。