首先,我有一个jsp页面:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<script type="application/javascript">
function download(){
var url="http://localhost:8080/wdxend/excelexport/testDownload";
window.open(url);
}
</script>
<body>
<input type="button" value="导出数据" οnclick="download()"/>
</body>
</html>
很久不玩,都不记得jsp怎么配得了。
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/static/"/>
<property name="suffix" value=".jsp"/>
</bean>
@RequestMapping("testjsp")
public ModelAndView test(){
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("status");
return modelAndView;
}
这是一个下载的Controller
@RequestMapping("testDownload")
public String testDownload(HttpServletRequest request, HttpServletResponse response/*, @RequestBody PieceCostParam pieceCostParam*/) throws Exception{
PieceCostParam pieceCostParam = new PieceCostParam();
PieceCostQuery