【发布时间】:2015-04-29 19:41:46
【问题描述】:
当 request.GetAttribute 为 null 时,如何从 textarea 中删除 null,以及如何从 servlet 修改标签的可见性? 在输入 textarea 上它不显示 request.getattribute 值,在输出 textarea 上它显示值但是当 request.getattirbute 为 null 时,在 textarea 上打印 null 并且我想删除它,如何?
<label>Type word/s here:</label></br>
<textarea name="Input" id="styleid">
<%
String msg=(String)request.getAttribute("Input");
if(msg==null)
{
msg="";
}
%>
</textarea> </br>
<input type="submit" class="styled-button-2" value="Translate" name="query" /> </br>
<textarea name="Output" id="styleid" text="" disabled>
<%=
request.getAttribute("Output")
%>
</textarea>
关于标签的可见性 JSP
<label for="Syllabication" class="
<%=request.getAttribute("Visibility")%>">Syllabication</label>
小服务程序
response.setContentType("text/html");
request.setAttribute("Visbility","hidden");
request.getRequestDispatcher("eng-chav.jsp").forward(request, response);
还有隐藏类
<style>
.hidden{
visibility:hidden;
}
</style>
【问题讨论】:
-
考虑使用核心jstl
c:if -
我不确定你能不能试试这个 request.getAttribute("Output")!=null。在这种情况下,如果不是 null ,它将显示文本区域和值。如果为null,它将显示文本区域并且值为空
-
返回布尔结果并显示
标签: java javascript css jsp servlets