当 request.GetAttribute 为 null 时如何从 textarea 中删除 null,以及如何从 servlet 修改标签的可见性
How can i remove the null from textarea when request.GetAttribute is null, and how can i modify the visibility of the label from the servlet
当 request.GetAttribute 为 null 时如何从 textarea 中删除 null,以及如何从 servlet 修改标签的可见性?
在输入 textarea 上它不显示 request.getattribute 值,在输出 textarea 上它显示值但是当 request.getattirbute 为 null 时,null 打印在 textarea 上,我想删除它,怎么样?
<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>
Servlet
response.setContentType("text/html");
request.setAttribute("Visbility","hidden");
request.getRequestDispatcher("eng-chav.jsp").forward(request, response);
和隐藏的class
<style>
.hidden{
visibility:hidden;
}
</style>
<%
String msg=(String)request.getAttribute("Input");
if(msg==null)
{
msg="";
}
%>
这不会输出任何内容,因为该值仅存储在 msg
中,不会在任何地方打印出来。您可能应该添加:
<%=
msg
%>
在其他文本区域中,您有:
<%=
request.getAttribute("Output")
%>
当你没有名为 "Output" 的属性时,它将打印出 null
。所以这可能是您看到的 null
的来源。
至于可见性问题,您只需添加另一个 class 即可,以备不时之需使元素再次可见。例如:
<style>
.hidden {
visibility: hidden;
}
.visible {
visibility: visible;
}
</style>
然后,您可以通过编写以下内容使该元素在您的 servlet 代码中可见:
request.setAttribute("Visbility","hidden");
当 request.GetAttribute 为 null 时如何从 textarea 中删除 null,以及如何从 servlet 修改标签的可见性? 在输入 textarea 上它不显示 request.getattribute 值,在输出 textarea 上它显示值但是当 request.getattirbute 为 null 时,null 打印在 textarea 上,我想删除它,怎么样?
<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>
Servlet
response.setContentType("text/html");
request.setAttribute("Visbility","hidden");
request.getRequestDispatcher("eng-chav.jsp").forward(request, response);
和隐藏的class
<style>
.hidden{
visibility:hidden;
}
</style>
<%
String msg=(String)request.getAttribute("Input");
if(msg==null)
{
msg="";
}
%>
这不会输出任何内容,因为该值仅存储在 msg
中,不会在任何地方打印出来。您可能应该添加:
<%=
msg
%>
在其他文本区域中,您有:
<%=
request.getAttribute("Output")
%>
当你没有名为 "Output" 的属性时,它将打印出 null
。所以这可能是您看到的 null
的来源。
至于可见性问题,您只需添加另一个 class 即可,以备不时之需使元素再次可见。例如:
<style>
.hidden {
visibility: hidden;
}
.visible {
visibility: visible;
}
</style>
然后,您可以通过编写以下内容使该元素在您的 servlet 代码中可见:
request.setAttribute("Visbility","hidden");