1

カスタムjspタグで非常に奇妙な問題が発生しました。Tomcat6にデプロイしたときに正常に機能していたものが、Tomcat7環境では機能していません。これが私のタグハンドラークラスです:

private Long millis;

/**
 * Constructor
 */
public ConvertMillisecondsValueTag() {
    super();
    millis = null;
}

/**
 * Tag name
 */
public String getTagName() {
    return "convertMillisValueTag";
}

public Long getMillis() {
    return this.millis;
}


public void setMillis(Long millis) {
    this.millis = millis;
}

/**
 * EVAL_PAGE
 */
public int doEndTag() throws JspTagException {

    StringBuilder buff = new StringBuilder();
    long timeInSeconds = this.millis/1000;
    int seconds = (int)(timeInSeconds % 60);  
    int minutes = (int)((timeInSeconds % 3600) / 60);  
    int hours = (int)((timeInSeconds % 86400) / 3600);
    int days = (int)((timeInSeconds / 86400));
    if (days > 0) {
        buff.append(days + " d, ");
    }
    if (hours > 0) {
        buff.append(hours + " h, ");
    }
    if (minutes > 0) {
        buff.append(minutes + " min, ");
    }
    if (seconds > 0) {
        buff.append(seconds + " sec");
    }
    try {
        pageContext.getOut().print(buff.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }       

    return TagSupport.EVAL_PAGE;
}

/**
 * Release this instance of tag
 */
public void release() {
    this.millis = null;
}

そしてここに私のtld定義:

<?xml version="1.0" encoding="UTF-8"?>

http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd "version =" 2.0 ">

<description>Itedge JSP Tag Library</description>
<tlib-version>1.0</tlib-version>
<short-name>itedge</short-name>
<uri>http://www.itedge.sk/tags</uri>

<tag>
    <description>
        Takes milliseconds input (long) and displays it in
        second, minutes, hours and days
    </description>
    <name>convertMillisValue</name>
    <tag-class>com.itedge.solutionmanager.web.tags.ConvertMillisecondsValueTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>Milliseconds input (long).</description>
        <name>millis</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
</tag>      

タグの使用法は次のとおりです。

プロジェクトをtomcat6にデプロイすると、ミリ秒値を変換して表示しますが、tomcat 7では何も出力されません。また、デバッグモードのdoEndTagメソッドでブレークポイントを設定すると、ブレークポイントの一致がありません。 。何か考えがありますか、何が間違っている可能性がありますか?tomcat6はサーブレット2.5apiを使用し、tomcat7は3.0サーブレットapiを使用することを知っています。これが私が持っている唯一の手がかりです。

4

1 に答える 1

0

おそらく:

<%@ taglib prefix="itedge" uri="http://www.itedge.sk/tags" %>

次のように置き換える必要があります。

<%@ taglib prefix="itedge" uri="/WEB-INF/tlds/yourFilename.tld" %>
于 2011-11-18T07:14:43.340 に答える