[英]Read Object from HttpServletRequest in Spring controller
I am sending class object to my spring controller. 我正在将类对象发送给我的spring控制器。 But the HttpServletRequest accept only String not object.Here is my code 但是HttpServletRequest只接受String而不是对象。这是我的代码
download.jsp 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>
But I need the following QueryResult object from HttpServletResquest not string. 但是我需要来自HttpServletResquest的以下QueryResult对象而不是字符串。
QueryResult result = request.getParameter("data");
Help me.Thanks in advance. 帮帮我。谢谢。
I think that you can help you to fix this. 我认为您可以帮助您解决此问题。 change this 改变这个
@RequestMapping(value="/excelDownload", method = RequestMethod.GET)
private ModelAndView excelDownload(HttpServletRequest request)
{
with 与
@RequestMapping(value="/excelDownload", method = RequestMethod.GET)
private ModelAndView excelDownload(HttpServletRequest
request,@RequestParam YourObject
object)
{ .....}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.