page.tld 已经在WEB-INF目录下面了吗?
解决方案 »
- Service层返回错误信息,异常 or 返回值 ?
- ------求助JavaEE------
- 关于HttpClient返回XML的问题
- 使用javaMail发送邮件内容不能正确显示
- Java+数据库开发项目对视图层和数据库相关操作出现乱码汇总资料?
- tomcal中的server.xml配置数据库连接出错,请指点,谢谢
- 如何对JAVA类进行加密
- 请问哪位能提供jxl
- 找开源的JMS Server(非集成)。
- 哪位知道 weblogic 的“automatic-key-generation”的用法,worldheart 大哥进来看看啊
- 什么是真正优秀的 Java Report 工具?!
- 为什么我的Class.forName(类名)得不到我的类
// DateTag.java
package com.liad.jsptaglibs.date;import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;/**
* A custom tag that displays the current date.
*
* @author Simon Brown
*/
public class DateTag extends TagSupport { /**
* Called when the starting tag is encountered.
*/
public int doStartTag() throws JspException { // get the locale of the client and create an appropriate date format
Locale loc = pageContext.getRequest().getLocale();
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, loc); try {
// and write out the formatted date to the page
pageContext.getOut().write(df.format(new Date()));
} catch (java.io.IOException ioe) {
throw new JspTagException(ioe.getMessage());
} // and skip evaluating the body of the tag (as there shouldn't be one)
return SKIP_PAGE;
}}simple.tld
==========
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"><taglib> <tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>simple</short-name>
<description>Examples for the Simple Tags chapter</description>
<tag>
<name>date</name>
<tag-class>com.liad.jsptaglibs.date.DateTag</tag-class>
<body-content>empty</body-content>
<description>Inserts the current date into the page</description>
</tag>
</taglib>web.xml
=======
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'><web-app>
<display-name>Professional JSP Tag Libraries</display-name>
<taglib>
<taglib-uri>/simpleTaglib</taglib-uri>
<taglib-location>/WEB-INF/tlds/simple.tld</taglib-location>
</taglib>
</web-app>datetag.jsp
===========
<html> <head>
<title>Professional JSP Tag Libraries</title>
</head> <%@ taglib uri="/simpleTaglib" prefix="simple" %> <body> <h1>The date is <simple:date/></h1> </body></html>用dos命令tree /f获得的目录结构是
tagtest
│ datetag.jsp
│
└─WEB-INF
│ web.xml
│
├─classes
│ └─com
│ └─liad
│ └─jsptaglibs
│ └─date
│ DateTag.class
│
└─tlds
simple.tld
struts本身带的那些taglib用起来没有问题吗?
假如要是没有问题,我想可能就是你的taglib有问题。
<taglib>
<taglib-uri>/WEB-INF/page.tld</taglib-uri>
<taglib-location>/WEB-INF/page.tld</taglib-location>
</taglib>