[英]How to use the “result” from <sql:query var=“result”>
I have this code: 我有这个代码:
<sql:query var="result"
sql="select column_name from information_schema.columns where table_name='userdb';"
/>
What does result
store and how can I use it to retrieve my data? result
存储什么,如何使用它检索数据?
The <sql:query>
documentation explains what's inside the result
variable: <sql:query>
文档说明了result
变量中的内容:
The type of the scoped variable is javax.servlet.jsp.jstl.sql.Result 作用域变量的类型为javax.servlet.jsp.jstl.sql.Result
The javax.servlet.jsp.jstl.sql.Result
is a sort of wrapper over a java.sql.ResultSet
and has methods to get to the rows of data . javax.servlet.jsp.jstl.sql.Result
是对java.sql.ResultSet
的一种包装,并且具有获取数据行的方法 。 It's then just a matter of <c:forEach>
ing the rows. 然后只需<c:forEach>
行即可。 See here for an example. 请看这里的例子。
PS Unless used for prototyping your application, using JSTL's SQL tags to access the database from within the JSP is discouraged. PS不建议使用JSTL的SQL标记从JSP内部访问数据库,除非用于对应用程序进行原型制作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.