Java 里 out.print() 不工作
我在out.print里打出这样:out.print("<Ahref='#'onclick='Javascript:window.open('Logon.jsp','',...
我在out.print里打出这样:
out.print("<A href='#' onclick='Javascript:window.open('Logon.jsp','','width=400,height=220')'>登录</A>")
但是运行后无法弹出新窗口
要怎么解决? 展开
out.print("<A href='#' onclick='Javascript:window.open('Logon.jsp','','width=400,height=220')'>登录</A>")
但是运行后无法弹出新窗口
要怎么解决? 展开
4个回答
展开全部
你里面的引号打乱了。 去掉两个引号试一试:
out.print("<A href='#' onclick=Javascript:window.open('Logon.jsp','','width=400,height=220')>登录</A>")
或者改为:
out.print("<A href='#' onclick=\"Javascript:window.open('Logon.jsp','','width=400,height=220')\">登录</A>")
看看
out.print("<A href='#' onclick=Javascript:window.open('Logon.jsp','','width=400,height=220')>登录</A>")
或者改为:
out.print("<A href='#' onclick=\"Javascript:window.open('Logon.jsp','','width=400,height=220')\">登录</A>")
看看
展开全部
直接在jsp页面上写:<%out.print("<a href='#' onclick=\"JavaScript:window.open('Logon.jsp','','width=400,height=220')\">登录</a>");%>
\"转义为"
\"转义为"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
//我给个完整的servlet
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class HiServlet extends javax.servlet.http.HttpServlet implements
javax.servlet.Servlet {
static final long serialVersionUID = 1L;
public HiServlet() {
super();
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// 改成你的页面
String dist = "http://www.baidu.com";
String s = "<A href='#' onclick=\"Javascript:window.open('" + dist
+ "','','width=400,height=220')\">" + dist + "</A>";
PrintWriter writer = response.getWriter();
writer.print(s);
writer.flush();
}
}
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class HiServlet extends javax.servlet.http.HttpServlet implements
javax.servlet.Servlet {
static final long serialVersionUID = 1L;
public HiServlet() {
super();
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// 改成你的页面
String dist = "http://www.baidu.com";
String s = "<A href='#' onclick=\"Javascript:window.open('" + dist
+ "','','width=400,height=220')\">" + dist + "</A>";
PrintWriter writer = response.getWriter();
writer.print(s);
writer.flush();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你是在servlet里面打印的吧?
那个要有前后文的 不能只打印这一句
那个要有前后文的 不能只打印这一句
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |