Java 里 out.print() 不工作

来源:百度知道 编辑:UC知道 时间:2024/06/20 15:43:02
我在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>")
或者改为:
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 {