可以在JSP中创建引用绝对路径的一个taglib,这样的话就不许要在WEB.XML中声明了。如:<%@ page contentType="text/html;charset=UTF-8" language="java" %><%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %><%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %><%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %><%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!-- start taglib --> <%@ include file="/includes/taglibs.inc.jsp" %> <!-- end taglib --> <html:html> <body> ... 当你用绝对URL指定taglib时,你不需要将相应的taglib中加入到web.xml中去。 Servlet2.3之前必须在web.xml中声明taglib 从2.3开始才可以使用绝URI。绝对URI是由相应的TLD文件确定的。 如果你想在整个应用程序中使用同一个talib库,可以创建一个包含taglib的文件,然后将此文件包含到任意的JSP页面中去。 struts1.1和struts1.2中的taglib是有区别的: Tag library Struts 1.1 URI Struts 1.2 URI struts-bean http://jakarta.apache.org/struts/tags-bean http://struts.apache.org/tags-bean struts-html http://jakarta.apache.org/struts/tags-html http://struts.apache.org/tags-html struts-logic http://jakarta.apache.org/struts/tags-logic http://struts.apache.org/tags-logic struts-nested http://jakarta.apache.org/struts/tags-nested http://struts.apache.org/tags-nested struts-template http://jakarta.apache.org/struts/tags-template No longer included with Struts; replaced by Tiles struts-tiles http://jakarta.apache.org/struts/tags-tiles http://struts.apache.org/tags-tiles struts-bean-el http://jakarta.apache.org/struts/tags-bean-el http://struts.apache.org/tags-bean-el struts-html-el http://jakarta.apache.org/struts/tags-html-el http://struts.apache.org/tags-html-el struts-logic-el http://jakarta.apache.org/struts/tags-logic-el http://struts.apache.org/tags-logic-el

评论