out.println("<script language='javascript'>alert('增加成功!');</script>");
forward.setPath("/gs_yuangongxinxi.do?method=initPage");
forward.setRedirect(true);-----------------------------------------------
把
forward.setPath("/gs_yuangongxinxi.do?method=initPage");
forward.setRedirect(true);
注释了。试试
forward.setPath("/gs_yuangongxinxi.do?method=initPage");
forward.setRedirect(true);-----------------------------------------------
把
forward.setPath("/gs_yuangongxinxi.do?method=initPage");
forward.setRedirect(true);
注释了。试试
解决方案 »
- webserice拒绝访问:FileNotFoundExceptpion
- txt文件解析同步到数据库
- struts1新手求助
- MapXtreme的问题。
- TOMCAT不能启动,出现奇怪错误,很头痛,寻求帮助
- 求助:<logic:iterate > 内存在><html:text > 问题
- 各位如何取数据库字段注释呢?
- oracle char(2)字段,其值为"00",可用getString()取出后,变成"00 ",why?
- tomcat的server.xml 和web.xml 有谁看的懂吗?
- java 正则表达式里的分组啥意思啊 谁能通熟易懂的举个例子讲下呢
- Missing message for key "hello.jsp.title"
- 关于url传参中文字符乱码,超奇怪的问题
一般的做法是使用Tag或者设置标志位,在FormLoad时判断标志位,来弹出提示
+ request.getLocalPort() + "/yyt";
response.setCharacterEncoding("gb2312");
PrintWriter out = response.getWriter();
out.println("<script type=\"text/javascript\">");
out.println("alert(\"密码错误,请重新登陆!\")");
out.println("parent.location=\"" + url + "\"");
out.println("</script>");
out.close();
out = null;
if (insertflag==true)----------------------------------------------------------
pengtao0615(Class 涛):能在我的代码上直接改造吗?谢谢
JSP上根据标志符确定要alert的内容这种方法简单!!加个逻辑判断,js写在逻辑判断里,就可以阻止"刷新"action:request.setAttribute("IfRecord","N");jsp:<logic:notEmpty name="IfRecord">
<logic:equal name="IfRecord" value="N">
<script>
alert("没有记录!");
</script>
</logic:equal>
</logic:notEmpty>
try {
out.println("<script language='javascript'>alert('增加成功!');window.location.href='/gs_yuangongxinxi.do?method=initPage';</script>");
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} }
//***************
把上面的一句改为三句:
out.println("<script language='javascript'>");
out.println("alert('增加成功!')");
out.println("</script>");试试先。。
?
你必须清楚:服务器端的先运行,数据没有发送到客户端,已经在服务器端转向了。学习之。
?
out.println("<script language='javascript'>alert('增加成功!');</script>");
forward.setPath("/gs_yuangongxinxi.do?method=initPage");
forward.setRedirect(true);-----------------------------------------------
把
forward.setPath("/gs_yuangongxinxi.do?method=initPage");
forward.setRedirect(true);
注释了。试试--------------------------------------------------------谁说这样不行啊,我刚试完,可以的。
forward.setPath("/gs_yuangongxinxi.do?method=initPage");
forward.setRedirect(true);
返回如果解决
信息如下:type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception java.lang.NullPointerException
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:372)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.dsweb.filter.EnCodeFilter.doFilter(EnCodeFilter.java:54)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
if ("1".equals(request.getParameter("insert"))){
out.println("<script language='javascript'>alert('增加成功!');</script>"); }
笔记本送给你!!!!!!!!!!看看不要钱!!!帮忙点一下,让ME得个笔记本!!!自己注册个,没准也能弄个本本呢.
嘿嘿!
forward.setRedirect(true);重定向到另1个请求gs_yuangongxinxi.do请求应该对应的是另一个ACTION吧,而不是JSP页面
action里面加个方法
protected void forwardHistory(HttpServletResponse response, String alert) {
response.setContentType("text/html; charset=GBK");
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
out.write("<script language='javascript'>");
if (alert == null || alert.equals("")) {
out.write("history.back();");
} else {
out.write("window.alert('" + alert + "!');history.back();");
}
out.write("</script>");
}extcute方法里面调用:
this.forwardHistory(response, "请先登录");
return null;搞定!
protected void forward(HttpServletResponse response, String alert,
String forward) {
response.setContentType("text/html; charset=GBK");
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
out.write("<script language='javascript'>");
if (alert == null || alert.equals("")) {
if (forward == null || forward.equals("")) {
out
.write("window.opener.document.location.reload();window.close();");
} else {
out.write("window.location.href='" + forward + "';");
}
} else {
if (forward == null || forward.equals("")) {
out
.write("window.alert('"
+ alert
+ "!');window.opener.document.location.reload();window.close();");
} else {
out.write("window.alert('" + alert
+ "!');window.location.href='" + forward + "';");
}
}
out.write("</script>");
}================================
if (insertflag==true){
this.forward(response, "增加成功!", "/gs_yuangongxinxi.do?method=initPage
// forward = "memberaddup";
return null;
/*try {
out.println("<script language='javascript'>alert('');</script>");
forward.setPath("/gs_yuangongxinxi.do?method=initPage");
forward.setRedirect(true);
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
return forward;*/
}
request.setAttribute("message", "<script type=\"text/javascript\" language=\"javascript\">alert('修改成功!')</script>");
jsp中这样就好了: <logic:present name="message">
<bean:wirte name="message" filter="false"/>
<script type="text/javascript" language="javascript">
window.location="";
</script>
</logic:present>