JSP弹出对话框方式小结
转自:http://blog.csdn.net/ithomer/article/details/8033002
该博主(创业)另一博客地址:
http://blog.mimvp.com
JSP 网页在与用户交互的过程中,有时需要弹出提示框,通知用户一些信息,如登录密码错误等
在做JSP网页项目中, 实践并总结了三种有效的方式
方式1: JSP前端
<script type="text/javascript" language="javascript">
alert("您还没有登录,请登录...");
window.document.location.href="userlogin.html";
</script>
方式2: Java后台
public void popAlert() {
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.print("<script>alert('您还没有登录,请登录...'); window.location='userlogin.html' </script>");
out.flush();
out.close();
}
方式3: Java后台 + JSP前端
1) Java后台代码段
public void popAlert() {
request.setAttribute("loginError", "您还没有登录,请登录..."); // 设置错误属性
request.getRequestDispatcher("userlogin.html").forward(request, response);
}
2) JSP前端代码段
<%
String errorInfo = (String)request.getAttribute("loginError"); // 获取错误属性
if(errorInfo != null) {
%>
<script type="text/javascript" language="javascript">
alert("<%=errorInfo%>"); // 弹出错误信息
window.location='userlogin.html' ; // 跳转到登录界面
</script>
<%
}
%>
总结
三种方式,实质都是通过JavaScript弹出对话框,提示用户密码错误,当用户点击alert确定按钮后,自动跳转到登录界面userlogin.html
JSP弹出对话框方式小结的更多相关文章
- JS弹出对话框的三种方式
JS弹出对话框的三种方式 我们用到了alert()方法.prompt()方法.prompt()方法,都是在网页有一个弹出框,那么就让我们探究一下他们之间的区别: 一.第一种:alert()方法 < ...
- JSP弹出窗口和模式对话框
本文转载于其它blog,在此向本文原创者,致意! JSP 弹出窗口 一.window.open() 基础知识 1.window.open()支持环境: JavaScript1.0+ ...
- 【JSP】三种弹出对话框的用法实例
对话框有三种 1:只是提醒,不能对脚本产生任何改变: 2:一般用于确认,返回 true 或者 false ,所以可以轻松用于 if...else...判断 3: 一个带输入的对话框,可以返回用户填入的 ...
- js弹出对话框的三种方式(转)
原文地址:https://www.jb51.net/article/81376.htm javascript的三种对话框是通过调用window对象的三个方法alert(),confirm()和prom ...
- ABAP 弹出对话框
一组有用的用户交互窗口函数 显示多条消息 SAP系统用的是这个函数:C14Z_MESSAGES_SHOW_AS_POPUP POPUP_TO_CONFIRM_LOSS_OF_DATA 显示有YES/N ...
- SharePoint 2010 Pop-Up Dialogs SharePoint 2010 弹出对话框
SharePoint 2010 Pop-Up Dialogs SharePoint 2010 弹出对话框 SharePoint 2010 使得往你的站点加入对话框内容变得出乎意料的简单 ...
- 10.JAVA之GUI编程弹出对话框Dialog
在上节基础上添加对话框显示错误信息. 代码如下: /*弹出对话框显示错误信息,对话框一般不单独出现,一般依赖于窗体.*/ /*练习-列出指定目录内容*/ import java.awt.Button; ...
- 【Telerik】弹出对话框RadWindow,确认删除信息
要做一个删除功能,但是删除前正常都要弹出对话框确认一下是否删除信息,防止误删信息.
- Response.Write("<script>alert('弹出对话框!')</script>") 后跟Response.Redirect("page.aspx");不能弹出对话框,直接跳转页面了 如何解?
Response.Write和Response.Redirect一起用的时候就会这样,write脚本和redirect脚本不能同时使用,这样不会执行脚本,最好使用ClientScript 改进方法: ...
随机推荐
- ASP.NET MVC2之Model Binder
Model Binder在Asp.net MVC中非常简单.简单的说就是你控制器中的Action方法需要参数数据:而这些参数数据包含在HTTP请求中,包括表单上的Value和URL中的参 数等.而Mo ...
- IOS 沙盒与清除缓存
SandBox,沙盒机制,是一种安全体系.我们所开发的每一个应用程序在设备上会有一个对应的沙盒文件夹,当前的程序只能在自己的沙盒文件夹中读取文件,不能访问其他应用程序的沙盒.在项目中添加的所有非代码的 ...
- JAVA-错误The type BookServiceImpl must implement the inherited abstract method
错误原因 :是因为class继承了其他的类,没有导入过来,选择add unimplemented methods进行解决
- echarts文档对照
echarts的各种配置项可以对照这个文档: https://echarts.baidu.com/echarts2/doc/option.html#title~tooltip.axisPointer. ...
- [Functional Programming] Using JS, FP approach with Arrow or State Monad
Using Naive JS: const {modify, get} = require('crocks/State'); const K = require('crocks/combinators ...
- 10.2.1itools导入不了歌曲
首先下载iTools 4抢先版,下载地址:http://update2.itools.hk/api/v1/redirect?p=itools4&c=pc_Thinksky 点击电脑桌面左下方“ ...
- maven 配置篇 之pom.xml
http://www.blogjava.net/zyl/archive/2006/12/30/91055.html http://maven.apache.org/pom.html的翻译. m ...
- Activity设置Dialog属性点击区域外消失实现方式
通过配置:<item name="android:windowCloseOnTouchOutside">true</item> 通过代码:setFinish ...
- springboot项目中报错:listener does not currently know of SID given in connect descriptor
springboot项目中报错:listener does not currently know of SID given in connect descriptor 出现这个问题的原因是SID写错了 ...
- NSMutableURLRequest Http 请求 同步 异步
#pragma mark get country code//同步 -(void)getFKjsonCountryCode { dispatch_async(dispatch_get_global_q ...