將整型值轉(zhuǎn)為字符串

StringUtil6.java

public class StringUtil6 {
    private int intValue=0;
    private String strValue1;
    private String strValue2;
    private String strValue3;
    public StringUtil6(){}
    public int getIntValue() {
        return intValue;
    }
    public void setIntValue(int intValue) {
        this.intValue = intValue;
    }
    public String getStrValue1() {
        return String.valueOf(intValue);
    }
    public void setStrValue1(String strValue1) {
        this.strValue1 = strValue1;
    }
    public String getStrValue2() {
        return Integer.toString(intValue);
    }
    public void setStrValue2(String strValue2) {
        this.strValue2 = strValue2;
    }
    public String getStrValue3() {
        return Integer.valueOf(intValue).toString();
    }
    public void setStrValue3(String strValue3) {
        this.strValue3 = strValue3;
    }
    
}

index.jsp

<body>
    <%
        int userAge=35;
    %>
    <jsp:useBean id="strBean" class="com.count.StringUtil6"></jsp:useBean>
    <jsp:setProperty property="intValue" name="strBean" value="<%=userAge %>"/>
    <table>
        <tr bgcolor="skyblue">
            <td align="center">String.valueOf():</td>
        </tr>
        <tr>
            <td align="center">Age:<jsp:getProperty property="strValue1" name="strBean"/>歲</td>
        </tr>
        <tr bgcolor="skyblue">
            <td align="center">Integer.toString():</td>
        </tr>
        <tr>
            <td align="center">Age:<jsp:getProperty property="strValue2" name="strBean"/>歲</td>
        </tr>
        <tr bgcolor="skyblue">
            <td align="center">Integer.valueOf().toString():</td>
        </tr>
        <tr>
            <td align="center">Age:<jsp:getProperty property="strValue3" name="strBean"/>歲</td>
        </tr>
    </table>
</body>
7.PNG
8.PNG
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home...
    光劍書(shū)架上的書(shū)閱讀 4,183評(píng)論 2 8
  • JSP總結(jié)(經(jīng)典) day1 JSP 定義: 1)Java Server Page, Java EE 組件,本...
    91數(shù)據(jù)閱讀 3,635評(píng)論 0 13
  • 1.學(xué)習(xí)內(nèi)容 JSP技術(shù)入門(mén)和常用指令 JSP的內(nèi)置對(duì)象&標(biāo)簽介紹 EL表達(dá)式&EL的內(nèi)置對(duì)象 2.JSP技術(shù)入門(mén)...
    WendyVIV閱讀 2,324評(píng)論 1 18
  • 市場(chǎng)上,香椿52元一斤時(shí),那菠菜才5角一斤。 富人舉著一把香椿對(duì)那個(gè)舉著一捆菠菜的窮人說(shuō):“5毛錢(qián)一斤的菠菜,能吃...
    劉萬(wàn)軍L閱讀 197評(píng)論 1 1
  • 主人養(yǎng)了三只小龜,隨著時(shí)間的推移,小龜們?cè)絹?lái)越大,它們的龜缸越發(fā)擁擠,可粗心的主人并沒(méi)發(fā)現(xiàn)這點(diǎn)。 小龜們決定憑借自...
    余獨(dú)不覺(jué)樂(lè)媽閱讀 411評(píng)論 2 7

友情鏈接更多精彩內(nèi)容