![](/img/trans.png)
[英]I want to get values from JSP page to multiple jsp pages. Is it possible?
[英]i want to avoid scriptlets on my jsp pages. I have google it and search here too but i was not able to solve it
我已经阅读了许多帖子,小脚本是一个不好的做法,所以最后我决定避免这一点。 我使用struts框架开发了一个项目,其中大多数jsp页面都有java代码。 现在我想从我的所有页面中删除该代码。
<%@page import="java.sql.ResultSet"%>
<%@page import="com.pra.sql.SQLC"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<table align="left" width="346" border="0">
<tr><td align="center" colspan="3" style="font-size:20px;">Tests We Provide</td></tr>
<tr>
<th width="80" height="38" nowrap>Test ID</th>
<th width="200" nowrap>Test Name</th>
<th width="144" nowrap>Test Fee</th>
</tr>
<%
String sql = "Select TestID,tname,tfee from addtest order by tname";
ResultSet rs = SQLC.getData(sql, null);
while (rs.next()) {
String testid = rs.getString("TestID");
String testname = rs.getString("tname");
String testfee = rs.getString("tfee");
%>
<tr>
<td width="80" height="34" nowrap><%=testid%></td>
<td width="200" nowrap><%=testname%></td>
<td width="144" nowrap><%=testfee%></td>
</tr>
<%
}
%>
</table>
您可以编写自己的jsp标记,也可以使用JSTL。 JSTL是oracle(原来是sun)提供的标准标记库
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.