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
我已经阅读了很多文章,认为scriptlet是一种不好的做法,所以最终我还是决定避免这种情况。我使用struts框架开发了一个项目,其中大多数jsp页面都有Java代码。现在我想从所有页面中删除该代码。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <%@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)提供的标准标记库