【问题标题】:How to output value in textarea using JSTL in JSP如何在 JSP 中使用 JSTL 在 textarea 中输出值
【发布时间】:2021-08-10 04:26:08
【问题描述】:

我在jsp中使用JSTL,想在textarea中输出值

<tr>
    <th scope="row">SMS Before Inst</th>
    <td colspan="7"><textarea cols="20" rows="5" placeholder="SMS Content" id=smsMessage name="smsMessage">
        Time setting is
        <c:choose>
            <c:when test="${CTSSessionCode=='M'}">
                Morning 
            </c:when>
            <c:when test="${CTSSessionCode=='E'}">
                 Everning
            </c:when>
            <c:otherwise>
                OTHER
            </c:otherwise>
        </c:choose>   
        Date
        <c:out value="${requestDate}" ></c:out> 
        ,We will contact later
    </textarea></td>
</tr>

在里面,CTSSessionCode = M 是 Morning,CTSSessionCode = E 是 Everning,requestDate 是日期,但是当我运行它时,它的输出是空白和空格字符。

如何解决问题?

【问题讨论】:

    标签: jsp jstl


    【解决方案1】:

    &lt;textarea&gt;:

    <textarea>
    value
    </textarea>
    

    你可以试试这个:

    <textarea>value</textarea>
    

    并将&lt;c:choose&gt; 条件移到&lt;textarea&gt; 之外:

    <c:set var="myVar" value="OTHER"></c:set>
    
    <c:choose>
        <c:when test="${CTSSessionCode=='M'}">
            <c:set var="myVar" value="Morning"></c:set>
        </c:when>
        <c:when test="${CTSSessionCode=='E'}">
            <c:set var="myVar" value="Everning"></c:set>
        </c:when>
    </c:choose>
    
    <tr>
        <th scope="row">SMS Before Inst</th>
        <td colspan="7">
            <textarea cols="20" rows="5" placeholder="SMS Content" id=smsMessage name="smsMessage">Time setting is ${myVar} Date ${requestDate}, We will contact later</textarea>
        </td>
    </tr>
    

    【讨论】:

      猜你喜欢
      • 2015-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多