2011-08-30 19 views
1

カスタムjspタグで非常に奇妙な問題が発生しました - tomcat 6にデプロイされたときに動作していたものがtomcat 7環境で動作しません。ここに私のタグハンドラクラスは、次のとおりです。カスタムタグハンドラがtomcat 7では動作しませんが、tomcat 6で正常に動作しています

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」 バージョン= "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>  

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

私はTomcatの6でプロジェクトを展開するとき、それは、細かい作業ミリ秒の値を変換して表示しますが、Tomcatの7で、それは簡単なものを印刷しません、と私はデバッグ中のdoEndTagメソッドにブレークポイントを設定するときですモードでは、ブレークポイントの一致はありません。あなたは何か間違っていると思われますか?私は、Tomcat 6がサーブレット2.5のAPIを使用し、Tomcat 7が3.0のサーブレットAPIを使用していることを知っています。それは私が持っている唯一の手掛かりです。おそらく

答えて

0

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

あなたはそれを交換する必要があります。

<%@ taglib prefix="itedge" uri="/WEB-INF/tlds/yourFilename.tld" %> 
関連する問題