【问题标题】:How to use ResultSetMetaData in Spring-Hibernate Integration?如何在 Spring-Hibernate 集成中使用 ResultSetMetaData?
【发布时间】:2013-01-06 16:22:36
【问题描述】:

在我的 JSP 页面中,我在数据库中显示员工详细信息并以硬编码的形式给出表列名。现在我需要知道如何动态获取表列名?

我知道 ResultSetMetaData 只能在 JSP 中使用。但是我不知道在JSP中使用Spring-Hibernate集成时如何获取列名。

请任何人帮忙解决这个问题?

我的 JSP 页面将是,

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ include file="include.jsp" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<form:form action="displayuser.html"  commandName="displayuser">  


<table width="100%" align="center">

 <tr style="background-color:#6B8E23  ;">
  <td align="center">Employee Id</td>
  <td align="center">Employee Name</td>
  <td align="center">Employee Password</td>
    <td align="center">Gender</td>
  <td align="center">Designation</td>
 </tr>

 <core:forEach items="${DisplayuserDetail}" var="userObj">
    <tr style="background-color:#9ACD32 ;">
       <td align="center"><core:out value="${userObj.empId}"/></td>
       <td align="center"><core:out value="${userObj.empName}"/></td>
       <td align="center"><core:out value="${userObj.empPassword}"/></td>
       <td align="center"><core:out value="${userObj.gender}"/></td>
       <td align="center"><core:out value="${userObj.designation}"/></td>
    </tr>
 </core:forEach>

</table>

</form:form>

</body>
</html>

提前致谢...我们将不胜感激您的帮助...

【问题讨论】:

    标签: spring hibernate jsp spring-mvc


    【解决方案1】:

    如果您的 Hibernate 持久对象使用注释,您可以 read the annotations 关闭域对象。

    或者,看看this question on getting SQL column names 的答案是否有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-10
      • 1970-01-01
      • 1970-01-01
      • 2018-12-25
      • 2012-01-01
      相关资源
      最近更新 更多