JSTL 设置
程序员文章站
2022-06-19 08:23:57
...
å¨tomcat5.0 JSTLè¿éè¦èªå·²é
ç½®
è½ç¶JSTL计åæç»å°ä¸ä¸æ³¢Web容å¨ä¸ï¼ä½æ¨ç®åå¿ é¡»èªå·±è¿è¡è®¾ç½®ãæ以ä¸æ¥éª¤æä½ä»¥å°JSTLè£ è½½å°Web容å¨ä¸
1.ä» apache.orgä¸è½½ jakarta-taglibs-standard-current.tar.gz ã
2.解å缩ä¸è½½çæ件ã
3.å° jakarta-taglibs/standard-1.0.3/tld/c.tld æ·è´å° WEB/INF/tlds ç®å½ã
4.å° jakarta-taglibs/standard-1.0.3/lib ä¸çææJARæ件æ·è´å° WEB-INF/lib ç®å½ã
5.å°ä»¥ä¸æ¾ç¤ºçæ¡ç®æ·»å å° WEB-INF/web.xml é¨ç½²æ述符ä¸ã
6.éå¯Web容å¨ã
èå JSTLæ è®°
å¦ææ¨å¸æå¨JSP页é¢ä¸ä½¿ç¨ä»»ä½JSTLæ è®°ï¼æ¨é¦å å¿ é¡»å¨è¯¥é¡µé¢ä¸å£°ææ è®°åºåç¼åURLãæ们æ£å¨ä½¿ç¨æ ¸å¿JSTLåºï¼å æ¤ä½¿ç¨çæ ååç¼æ¯ c (代表 æ ¸å¿)ãæ¾ç¤ºå¢å äº taglib æ令çWebç«ç¹ç´¢å¼æ件ï¼
å¨åJSP页é¢æ·»å äºJSTL taglibä¹åï¼æ¨å¯ä»¥ä½¿ç¨æ ¸å¿åºä¸çä»»ä½æ è®°ï¼åªéææ è®°çåç¼æ¹ä¸º c ã为äºäºè§£è¿ä¸æµç¨ï¼æ们å°å°è¯æ页é¢ä» jsp:include æ 记转æ¢æ c:import æ è®°ã 表2æ¾ç¤ºäºæ¬ç³»å第äºé¨åä»ç»ç jsp:include å®ä¾(è§ åèèµæ)转为使ç¨æ° c:import æ è®°ã
è½ç¶JSTL计åæç»å°ä¸ä¸æ³¢Web容å¨ä¸ï¼ä½æ¨ç®åå¿ é¡»èªå·±è¿è¡è®¾ç½®ãæ以ä¸æ¥éª¤æä½ä»¥å°JSTLè£ è½½å°Web容å¨ä¸
1.ä» apache.orgä¸è½½ jakarta-taglibs-standard-current.tar.gz ã
2.解å缩ä¸è½½çæ件ã
3.å° jakarta-taglibs/standard-1.0.3/tld/c.tld æ·è´å° WEB/INF/tlds ç®å½ã
4.å° jakarta-taglibs/standard-1.0.3/lib ä¸çææJARæ件æ·è´å° WEB-INF/lib ç®å½ã
5.å°ä»¥ä¸æ¾ç¤ºçæ¡ç®æ·»å å° WEB-INF/web.xml é¨ç½²æ述符ä¸ã
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tlds/c.tld</taglib-location>
</taglib>
6.éå¯Web容å¨ã
èå JSTLæ è®°
å¦ææ¨å¸æå¨JSP页é¢ä¸ä½¿ç¨ä»»ä½JSTLæ è®°ï¼æ¨é¦å å¿ é¡»å¨è¯¥é¡µé¢ä¸å£°ææ è®°åºåç¼åURLãæ们æ£å¨ä½¿ç¨æ ¸å¿JSTLåºï¼å æ¤ä½¿ç¨çæ ååç¼æ¯ c (代表 æ ¸å¿)ãæ¾ç¤ºå¢å äº taglib æ令çWebç«ç¹ç´¢å¼æ件ï¼
<%@ page language="java" contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<head>
<title>newInstance.com</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<link href="/styles/default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<jsp:include page="header.jsp" flush="true">
<jsp:param name="pageTitle" value="newInstance.com"/>
<jsp:param name="pageSlogan" value=" " />
</jsp:include>
<%@ include file="/navigation.jsp" %>
<jsp:include page="bookshelf.jsp" flush="true" />
<jsp:include page="/mt-blogs/index.jsp" flush="true" />
<%@ include file="/footer.jsp" %>
</body>
</html>
å¨åJSP页é¢æ·»å äºJSTL taglibä¹åï¼æ¨å¯ä»¥ä½¿ç¨æ ¸å¿åºä¸çä»»ä½æ è®°ï¼åªéææ è®°çåç¼æ¹ä¸º c ã为äºäºè§£è¿ä¸æµç¨ï¼æ们å°å°è¯æ页é¢ä» jsp:include æ 记转æ¢æ c:import æ è®°ã 表2æ¾ç¤ºäºæ¬ç³»å第äºé¨åä»ç»ç jsp:include å®ä¾(è§ åèèµæ)转为使ç¨æ° c:import æ è®°ã
<%@ page language="java" contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<head>
<title>newInstance.com</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<link href="/styles/default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<jsp:include page="header.jsp" flush="true">
<jsp:param name="pageTitle" value="newInstance.com"/>
<jsp:param name="pageSlogan" value=" " />
</jsp:include>
<%@ include file="/navigation.jsp" %>
<c:import url="bookshelf.jsp" />
<c:import url="/mt-blogs/index.jsp" />
<%@ include file="/footer.jsp" %>
</body>
</html>