如何在单击链接时将java对象从jsp传递给spring控制器 [英] how to pass a java object from jsp to spring controller on clicking a link

查看:103
本文介绍了如何在单击链接时将java对象从jsp传递给spring控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在显示类型文档的Java对象列表,如下所示

I am displaying a list of Java objects of type documentation as follows

<c:forEach var="document" items="${documentationList}">
  <tr>
    <td valign="top" >${document.documentation}</td> <!-- c:out is not used here because, it is escaping HTML characters -->
    <td width="75" valign="top"><a href="" ><c:out value="${document.stateCode}" /></a></td>
    </c:when>
    <td width="75" valign="top"><c:out value="${document.type}" /></td>
  </tr>
</c:forEach>

州代码显示为超链接。我想要做的是,当点击链接时,我想将该特定的java对象('document')传递给java控制器,然后在新页面上显示更详细的信息。在春天有没有办法解决这个问题?(我正在使用spring MVC)。

State code is displayed as hyperlink. what i am trying to do is, when the link is clicked i want to pass that particular java object('document') to java controller and then display more detailed information on the new page. is there a way to this in spring ?( i am using spring MVC).

推荐答案

你只是在a之间使用常规HTTP浏览器和服务器。

You are just using regular HTTP between a browser and server.

对于GET请求,您可以在URL中传递信息,这就是它。

For a GET request, you can pass information in the URL, and that's about it.

您应该将文档的标识符(例如?docid = N)作为URL的一部分传递给服务器,然后在新请求中将该文档加载到服务器上。

You should pass an identifier for the document (like ?docid=N) to the server as part of the URL, and then load that document on the server in the new request.

如果文档没有唯一标识符,那么您可能必须将文档存储在会话中。

If there's no unique identifier for the document, then you would probably have to store the document in session.

这篇关于如何在单击链接时将java对象从jsp传递给spring控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆