我正在向我的弹簧控制器发送类对象。但是HttpServletRequest只接受String而不是object.Here是我的代码
download.jsp
<a class="download_excel view_download" >Download Full Excel</a>
<input type="hidden" class="result-object" value="${ReportDetails}" />
<script>
$(document).ready(function()
{
$('.view_download').click(function()
{
var object = $('.result-object').val();
window.location.href = "excelDownload.html?data="+object;
});
});
Controller file: HomeController.java
@RequestMapping(value="/excelDownload", method = RequestMethod.GET)
private ModelAndView excelDownload(HttpServletRequest request)
{
String result = request.getParameter("data");
return null;
}
</script>
但是我需要来自HttpServletResquest的以下QueryResult对象而不是字符串。
QueryResult result = request.getParameter("data");
帮帮我。谢谢。
答案 0 :(得分:0)
我认为你可以帮助你解决这个问题。 改变这个
@RequestMapping(value="/excelDownload", method = RequestMethod.GET)
private ModelAndView excelDownload(HttpServletRequest request)
{
带
@RequestMapping(value="/excelDownload", method = RequestMethod.GET)
private ModelAndView excelDownload(HttpServletRequest
request,@RequestParam YourObject
object)
{ .....}