JAVA中跳转问题 window.location.href

来源:百度知道 编辑:UC知道 时间:2024/06/15 21:32:39
我写了一个servlet
里面有这样的一个语句
out.println("<script language='javascript'>alert('删除成功!');window.location.href='跳转的页面';</script>");

当我是希望跳转的那个页面就是当前的页面,而不是到另外的一个页面.本来是可以写成这样的
out.println("<script language='javascript'>alert('删除成功!');window.location.href='XX.JSP';</script>");
但是因为当前的页面不是固定的那个页面,所以不能用XX.jsp来代替!
请问高手,我该怎么做,跳转的时候才是当前的页面!~
出现这样的错误
java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Integer.java:436)
java.lang.Integer.parseInt(Integer.java:518)
servlet.UpdateMail_BoxServlet.doPost(UpdateMail_BoxServlet.java:47)
servlet.UpdateMail_BoxServlet.doGet(UpdateMail_BoxServlet.java:79)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Integer.java:436)
java.lang.Integer.parseInt(Integer.java:518)

========================================
页面在要吧一个字符串转化为INT型时,结果传进来的值是空,所以报错了,你不能传一个JSP静态页面过去了,你要把那个页面的程序URL传进去,比如XXXAction.do?method=XX传过去,就可以处理后返回你要跳转的页面了,或者直接在转INT的那句话上加个判空处理

你可以把window.location.href的地址写成一个要验证的servlet ,然后在servlet中转发给本页面