如何在JSP中包含HTML? [英] How to include HTML in JSP?
本文介绍了如何在JSP中包含HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我搜索过这个问题,有一些答案,但不完全是我的问题。所以这是我的jsp代码:
i've searched for this question, there are some answers, but not exactly as my question. so here is my jsp code:
<body>
<%
if (manager.isValid(request.getParameter("username"),request.getParameter("password"))){
out.print("<h1> Welcome ");
out.print(request.getParameter("username") + "</h1>");
} else {
out.print("<h1> Please Try Again </h1> <br />");
out.print("Either your username or password is incorrect. Please Try again <br /> <br />");
}
%>
<%@ include file="LoginForm.html" %>
但不是这样,我想在else块中包含loginForm.html。
我该怎么办?
当然这不起作用,但你会猜到我想要的东西:
but instead of this, i want to include "loginForm.html" only in "else" block. how can i do it? of course this doesn't work, but you'll guess what i want :
<%
if (manager.isValid(request.getParameter("username"),request.getParameter("password"))){
out.print("<h1> Welcome ");
out.print(request.getParameter("username") + "</h1>");
} else {
out.print("<h1> Please Try Again </h1> <br />");
out.print("Either your username or password is incorrect. Please Try again <br /> <br />");
include file="LoginForm.html" ;
}
%>
推荐答案
我想告诉你一个方法,尝试像下面。您可以尝试使用else而不是,如果
。
I would like to show you a way, try like below. You can try with else instead with if
.
<body>
<%
int x = 10;
if(x>10) {
%>
<%@include file="some.html" %>
<%
}
%>
</body>
这篇关于如何在JSP中包含HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文