首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

web项目弹提示框小技能

2013-12-21 
web项目弹提示框小技巧??window.locationgoUrl?}else if(msg! && goUrlback){??alert(msg)??his

web项目弹提示框小技巧
??window.location=goUrl;
?}else if(msg!="" && goUrl=="back"){
??alert(msg);
??history.back();
?}else if(msg!="" && goUrl!="back"){
??alert(msg);
??window.location=goUrl;
?}
}

?

然后我们需要建一个接口类

public interface MyMsg {

?String ADD_SUCCESS = "addSuccess";
?String ADD_FAIL = "addFail";

}

?

再来建一个jsp页面 showMsg.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
? <head>
??? <title>提示信息</title>
? <script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/sqb.js"></script></head>??
? <body>
??? <c:set var="msg" value="${map.msg}" />
<c:choose>
??? <c:when test="${msg=='delSuccess'}">
??????? <script type="text/javascript">alertMsg("删除成功","跳转页面");</script>
??? </c:when>?
??? <c:when test="${msg=='delFail'}">
??????? <script type="text/javascript">alertMsg("删除失败.","跳转页面");</script>
??? </c:when>

</c:choose>
</body>
</html>

?

再action里面我们就可以这样写

public class?test extends ActionSupport?implements MyMsg{

????? @Action(value="activityList",results = {@Result(name=SUCCESS,location =?"/showMsg.jsp")})
????? public String test(){
??????? ?map.put("msg",ADD_SUCCESS);
?????? ? return SUCCESS;
?}

}

?

这样我们就完成了

热点排行