NETCTOSS项目(二)

来源:互联网 发布:邵阳学院网络教学平台 编辑:程序博客网 时间:2024/06/05 11:23

webapp文件下内容

cost文件夹下面的三个jsp

find.jsp

<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %><%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">    <head>        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        <title>达内-NetCTOSS</title>        <link type="text/css" rel="stylesheet" media="all" href="styles/global.css" />        <link type="text/css" rel="stylesheet" media="all" href="styles/global_color.css" />        <script language="javascript" type="text/javascript">            //排序按钮的点击事件            function sort(btnObj) {                if (btnObj.className == "sort_desc")                    btnObj.className = "sort_asc";                else                    btnObj.className = "sort_desc";            }            //启用            function startFee(btn) {            //获取当前状态-暂停时才有用            var tds = btn.parentNode.parentNode.getElementsByTagName("td");            var status = tds[7].innerHTML.trim();            if(status == "暂停"){            var r = window.confirm("确定要启用此资费吗?资费启用后将不能修改和删除。");            if(r == true){            //获取id            var id = tds[0].innerHTML.trim();            window.location.href = "startCost.do?costId="+id;            }            }            }                        //删除            function deleteFee(id) {                var r = window.confirm("确定要删除此资费吗?");                if(r == false){                return;                }                //确定删除时执行下列代码                window.location.href = "deleteCost.do?id="+id;            }        </script>            </head>    <body>        <!--Logo区域开始-->        <div id="header"><c:import url="../logo.jsp"></c:import>                   </div>        <!--Logo区域结束-->        <!--导航区域开始-->        <div id="navi">                                    <c:import url="../menu.jsp"/>              </div>        <!--导航区域结束-->        <!--主要区域开始-->        <div id="main">            <form action="" method="">                <!--排序-->                <div class="search_add">                    <div>                        <!--<input type="button" value="月租" class="sort_asc" onclick="sort(this);" />                        <input type="button" value="基费" class="sort_asc" onclick="sort(this);" />                        <input type="button" value="时长" class="sort_asc" onclick="sort(this);" />-->                    </div>                    <input type="button" value="增加" class="btn_add" onclick="location.href='toAddCost.do';" /><%-- 相对路径 --%>                </div>                 <!--删除操作的提示-->                <div id="operate_result_info" class="operate_success">                    <img src="images/close.png" onclick="this.parentNode.style.display='none';" />                    删除成功!                </div>                    <!--数据区域:用表格展示数据-->                     <div id="data">                                <table id="datalist">                        <tr>                            <th>资费ID</th>                            <th class="width100">资费名称</th>                            <th>基本时长</th>                            <th>基本费用</th>                            <th>单位费用</th>                            <th>创建时间</th>                            <th>开通时间</th>                            <th class="width50">状态</th>                            <th class="width200"></th>                        </tr>                        <c:forEach items="${costs }" var="c">                        <tr>                            <td>${c.costId }</td>                            <td><a href="fee_detail.html">${c.name }</a></td>                            <td>${c.baseDuration } 小时</td>                            <td>${c.baseCost } 元</td>                            <td>${c.unitCost } 元/小时</td>                            <td>                              <fmt:formatDate value="${c.creatime }" pattern="yyyy-MM-dd HH:mm:ss"/>                            </td>                            <td>                              <fmt:formatDate value="${c.startime }" pattern="yyyy-MM-dd HH:mm:ss"/>                            </td>                            <td>                              <c:if test="${c.status == '0' }">开通</c:if>                              <c:if test="${c.status == '1' }">暂停</c:if>                            </td>                            <td>                                                                <input type="button" value="启用" class="btn_start" onclick="startFee(this);" />                                <input type="button" value="修改" class="btn_modify"                                   onclick="location.href='toUpdateCost.do?id=${c.costId}';" />                                <input type="button" value="删除" class="btn_delete" onclick="deleteFee(${c.costId});" />                            </td>                        </tr>                        </c:forEach>                    </table>                    <p>业务说明:<br />                    1、创建资费时,状态为暂停,记载创建时间;<br />                    2、暂停状态下,可修改,可删除;<br />                    3、开通后,记载开通时间,且开通后不能修改、不能再停用、也不能删除;<br />                    4、业务账号修改资费时,在下月底统一触发,修改其关联的资费ID(此触发动作由程序处理)                    </p>                </div>                <!--分页-->                <div id="pages">                    <%-- 当前是第一页,点击上一页则没有效果 --%>                <c:if test="${page==1 }"><a href="">上一页</a></c:if>                <c:if test="${page!=1 }"><a href="findCost.do?page=${page-1 }">上一页</a></c:if>                    <%--                     begin:循环起始位置;                  end:循环终止位置;                     --%>                    <c:forEach begin="1" end="${total }" var="i">                     <%-- 若循环到了当前页,则将页码高亮显示 --%>                        <c:if test="${i==page }">                           <a href="findCost.do?page=${i }" class="current_page">${i }</a>                        </c:if>                    <%-- 若不是当前页,则去掉高亮的样式 --%>                        <c:if test="${i!=page }">                           <a href="findCost.do?page=${i }">${i }</a>                        </c:if>                    </c:forEach>                    <!-- 当前页是最后一页,则不能点下一页 -->                    <c:if test="${page==total }"><a href="">下一页</a></c:if>                    <c:if test="${page!=total }"><a href="findCost.do?page=${page+1 }">下一页</a></c:if>                                    </div>            </form>        </div>        <!--主要区域结束-->        <div id="footer">            <p>[源自北美的技术,最优秀的师资,最真实的企业环境,最适用的实战项目]</p>            <p>版权所有(C)加拿大达内IT培训集团公司 </p>        </div>    </body></html>


add.jsp

<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%><%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>达内-NetCTOSS</title><link type="text/css" rel="stylesheet" media="all"href="styles/global.css" /><link type="text/css" rel="stylesheet" media="all"href="styles/global_color.css" /><%-- 此处引入js --%><script type="text/javascript" src="js/judge.js"></script><script language="javascript" type="text/javascript">     //保存结果的提示(此部分未启用)       function showResult() {           showResultDiv(true);           window.setTimeout("showResultDiv(false);", 3000);       }       function showResultDiv(flag) {           var divResult = document.getElementById("save_result_info");           if (flag)               divResult.style.display = "block";           else               divResult.style.display = "none";       }     //切换资费类型       function feeTypeChange(type) {           var inputArray = document.getElementById("main").getElementsByTagName("input");           //三个资费input的下标为4、5、6           //错误提示还原(3个div)           document.getElementById("baseDuration_div").className = "validate_msg_long";           document.getElementById("baseCost_div").className = "validate_msg_long";           document.getElementById("unitCost_div").className = "validate_msg_long";           if (type == 1) {           inputArray[4].value= "";//清空           inputArray[4].readOnly = true;//只读           inputArray[4].className += " readonly";//添加背景           inputArray[5].readOnly = false;           inputArray[5].className = "width100";           inputArray[5].value = "";           inputArray[6].readOnly = true;;           inputArray[6].className += " readonly";           inputArray[6].value= "";           }           else if (type == 2) {           inputArray[4].readOnly = false;           inputArray[4].className = "width100";           inputArray[4].value = "";           inputArray[5].readOnly = false;           inputArray[5].className = "width100";           inputArray[5].value = "";           inputArray[6].readOnly = false;           inputArray[6].className = "width100";           inputArray[6].value = "";           }           else if (type == 3) {           inputArray[4].readOnly = true;           inputArray[4].className += " readonly";           inputArray[4].value = "";           inputArray[5].readOnly = true;           inputArray[5].className += " readonly";           inputArray[5].value = "";           inputArray[6].readOnly = false;           inputArray[6].className = "width100";           inputArray[6].value = "";           }       }        </script></head><body><!--Logo区域开始--><div id="header"><c:import url="../logo.jsp"></c:import></div><!--Logo区域结束--><!--导航区域开始--><div id="navi"><c:import url="../menu.jsp" /></div><!--导航区域结束--><!--主要区域开始--><div id="main"><div id="save_result_info" class="save_fail">保存失败,资费名称重复!</div><%-- 默认隐藏 --%><form action="addCost.do" method="post" class="main_form"onsubmit="return checkf();"><%-- 增加的资费名称不能与原有的相同 --%><div class="text_info clearfix"><span>资费名称:</span></div><div class="input_info"><input type="text" class="width300" id="cost_name" name="name"onblur="check_name()" /> <span class="required">*</span><div class="validate_msg_short" id="name_div">4-50长度字母、数字、汉字、下划线</div></div><div class="text_info clearfix"><span>资费类型:</span></div><div class="input_info fee_type"><input type="radio" name="costType" value="1" id="monthly"onclick="feeTypeChange(1);" /> <label for="monthly">包月</label> <inputtype="radio" name="costType" value="2" checked="checked"id="package" onclick="feeTypeChange(2);" /> <label for="package">套餐</label><input type="radio" name="costType" value="3" id="timeBased"onclick="feeTypeChange(3);" /> <label for="timeBased">计时</label></div><div class="text_info clearfix"><span>基本时长:</span></div><div class="input_info"><input type="text" class="width100" id="baseDuration"name="baseDuration" onblur="check_baseDuration();" /> <spanclass="info">小时</span> <span class="required">*</span><div class="validate_msg_long" id="baseDuration_div">1-600之间的整数</div></div><div class="text_info clearfix"><span>基本费用:</span></div><div class="input_info"><input type="text" class="width100" id="baseCost" name="baseCost"onblur="check_baseCost()" /> <span class="info">元</span> <spanclass="required">*</span><div class="validate_msg_long" id="baseCost_div">0-99999.99之间的数值</div></div><div class="text_info clearfix"><span>单位费用:</span></div><div class="input_info"><input type="text" class="width100" id="unitCost" name="unitCost"onblur="check_unitCost()" /> <span class="info">元/小时</span> <spanclass="required">*</span><div class="validate_msg_long" id="unitCost_div">0-99999.99之间的数值</div></div><div class="text_info clearfix"><span>资费说明:</span></div><div class="input_info_high"><textarea class="width300 height70" id="descr" name="descr"onblur="check_descr()"></textarea><div class="validate_msg_short" id="descr_div">100长度的字母、数字、汉字和下划线</div></div><div class="button_info clearfix"><input type="submit" value="保存" class="btn_save" /> <inputtype="button" value="取消" class="btn_save"onclick="location.href='findCost.do'" /></div><%-- 取消事件可以用histroy.back() --%></form></div><!--主要区域结束--><div id="footer"><span>[源自北美的技术,最优秀的师资,最真实的企业环境,最适用的实战项目]</span> <br /> <span>版权所有(C)加拿大达内IT培训集团公司</span></div></body></html>

update.jsp

<%@page pageEncoding="utf-8"  contentType="text/html; charset=utf-8"%><%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">    <head>        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        <title>达内-NetCTOSS</title>        <link type="text/css" rel="stylesheet" media="all" href="styles/global.css" />        <link type="text/css" rel="stylesheet" media="all" href="styles/global_color.css" />        <script type="text/javascript" src="js/judge.js"></script>        <script language="javascript" type="text/javascript">            //保存结果的提示(暂时未使用)            function showResult() {                showResultDiv(true);                window.setTimeout("showResultDiv(false);", 3000);            }            function showResultDiv(flag) {                var divResult = document.getElementById("save_result_info");                if (flag)                    divResult.style.display = "block";                else                    divResult.style.display = "none";            }          //切换资费类型            function feeTypeChange(type) {                var inputArray = document.getElementById("main").getElementsByTagName("input");                //三个资费input的下标为2、3、4                //错误提示还原(3个div)                document.getElementById("baseDuration_div").className = "validate_msg_long";                document.getElementById("baseCost_div").className = "validate_msg_long";                document.getElementById("unitCost_div").className = "validate_msg_long";                if (type == 1) {                inputArray[5].value= "";//清空                inputArray[5].readOnly = true;//只读                inputArray[5].className += " readonly";//添加背景                inputArray[6].readOnly = false;                inputArray[6].className = "width100";                inputArray[6].value = "";                inputArray[7].readOnly = true;;                inputArray[7].className += " readonly";                inputArray[7].value= "";                }                else if (type == 2) {                inputArray[5].readOnly = false;                inputArray[5].className = "width100";                inputArray[5].value = "";                inputArray[6].readOnly = false;                inputArray[6].className = "width100";                inputArray[6].value = "";                inputArray[7].readOnly = false;                inputArray[7].className = "width100";                inputArray[7].value = "";                }                else if (type == 3) {                inputArray[5].readOnly = true;                inputArray[5].className += " readonly";                inputArray[5].value = "";                inputArray[6].readOnly = true;                inputArray[6].className += " readonly";                inputArray[6].value = "";                inputArray[7].readOnly = false;                inputArray[7].className = "width100";                inputArray[7].value = "";                }            }        </script>    </head>    <body>        <!--Logo区域开始-->        <div id="header">           <c:import url="../logo.jsp"></c:import>                </div>        <!--Logo区域结束-->        <!--导航区域开始-->        <div id="navi">            <c:import url="../menu.jsp"/>        </div>        <!--导航区域结束-->        <!--主要区域开始-->        <div id="main">                        <div id="save_result_info" class="save_success">保存成功!</div>            <form action="updateCost.do" method="post" class="main_form" onsubmit="return checkf()">                <div class="text_info clearfix"><span>资费ID:</span></div>                <div class="input_info">                <input type="text" class="readonly" readonly value="${cost.costId }" name="costId"/>                </div>                <div class="text_info clearfix"><span>资费名称:</span></div>                <div class="input_info">                    <input type="text" class="width300"  id="cost_name" value="${cost.name }" name="name" onblur="check_name()"/>                    <span class="required">*</span>                    <div class="validate_msg_short" id="name_div">4-50长度的字母、数字、汉字、下划线</div>                </div>                <div class="text_info clearfix"><span>资费类型:</span></div>                <div class="input_info fee_type">                    <input type="radio" name="costType" id="monthly" value="1"                    <c:if test="${cost.costType == 1 }">checked</c:if> onclick="feeTypeChange(1);" />                    <label for="monthly">包月</label>                    <input type="radio" name="costType" id="package" value="2"                    ${cost.costType == 2?'checked':''}  onclick="feeTypeChange(2);" />                    <label for="package">套餐</label>                    <input type="radio" name="costType" id="timeBased" value="3"                    ${cost.costType == 3?'checked':'' } onclick="feeTypeChange(3);" />                    <label for="timeBased">计时</label>                </div>                <div class="text_info clearfix"><span>基本时长:</span></div>                <div class="input_info">                    <input type="text" value="${cost.baseDuration }" class="width100" id="baseDuration" name="baseDuration" onblur="check_baseDuration()"/>                    <span class="info">小时</span>                    <span class="required">*</span>                    <div class="validate_msg_long"  id="baseDuration_div">1-600之间的整数</div>                </div>                <div class="text_info clearfix"><span>基本费用:</span></div>                <div class="input_info">                    <input type="text" value="${cost.baseCost }" id="baseCost" class="width100" name="baseCost" onblur="check_baseCost()"/>                    <span class="info">元</span>                    <span class="required">*</span>                    <div class="validate_msg_long" id="baseCost_div">0-99999.99之间的数值</div>                </div>                <div class="text_info clearfix"><span>单位费用:</span></div>                <div class="input_info">                    <input type="text" value="${cost.unitCost }" id="unitCost" class="width100" name="unitCost" onblur="check_unitCost()"/>                    <span class="info">元/小时</span>                    <span class="required">*</span>                    <div class="validate_msg_long"  id="unitCost_div">0-99999.99之间的数值</div>                </div>                   <div class="text_info clearfix"><span>资费说明:</span></div>                <div class="input_info_high">                    <textarea class="width300 height70" id="descr" name="descr" onblur="check_descr()">${cost.descr }</textarea>                    <div class="validate_msg_short" id="descr_div">100长度的字母、数字、汉字和下划线</div>                </div>                                    <div class="button_info clearfix">                    <input type="submit" value="保存" class="btn_save" />                    <input type="button" value="取消" class="btn_save" onclick="location.href='findCost.do'"/>                </div>            </form>        </div>        <!--主要区域结束-->        <div id="footer">            <span>[源自北美的技术,最优秀的师资,最真实的企业环境,最适用的实战项目]</span>            <br />            <span>版权所有(C)加拿大达内IT培训集团公司 </span>        </div>    </body></html>

WEB-INF下文件(公用)

error.jsp

<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">    <head>        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        <title>达内-NetCTOSS</title>        <link type="text/css" rel="stylesheet" media="all" href="styles/global.css" />        <link type="text/css" rel="stylesheet" media="all" href="styles/global_color.css" />        <script language="javascript" type="text/javascript">            var timer;            //启动跳转的定时器            function startTimes() {                timer = window.setInterval(showSecondes,1000);            }            var i = 5;            function showSecondes() {                if (i > 0) {                    i--;                    document.getElementById("secondes").innerHTML = i;                }                else {                    window.clearInterval(timer);//公用文件一般都写绝对路径                    location.href = "/netctoss/toLogin.do";                }            }            //取消跳转            function resetTimer() {                if (timer != null && timer != undefined) {                    window.clearInterval(timer);                    location.href = "/netctoss/toLogin.do";                }            }        </script>     </head>    <body class="error_page" onload="startTimes();">        <h1 id="error">        遇到错误, <span id="secondes">5</span> 秒后将自动跳转,立即跳转请点击             <a  href="javascript:resetTimer();">返回</a>        </h1>    </body></html>

logo.jsp

<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %><img src="images/logo.png" alt="logo" class="left"/><%-- 利用EL表达式取cookie中的值  默认取值page request session application EL可以从cookie中取值  --cookie.key.value 下面cookie.adminCode获取的是cookie对象,还需要获取value值--%><%-- 利用cookie  <span>${cookie.adminCode.value  }</span> --%> <%-- sessionScope可以省略--%><span>${sessionScope.adminCode }</span><%-- 此处采用绝对路径 --%><a href="/netctoss/logout.do">[退出]</a> 

menu.jsp

<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%><%-- menu.jsp被其他jsp所公用,无法预估其目前的路径,所以相对路径不太合适,使用绝对路径 --%><ul id="menu">   <li><a href="/netctoss/toIndex.do" class="index_off"></a></li>   <li><a href="" class="role_off"></a></li>   <li><a href="" class="admin_off"></a></li>   <li><a href="/netctoss/findCost.do" class="fee_off"></a></li>   <li><a href="" class="account_off"></a></li>   <li><a href="" class="service_off"></a></li>   <li><a href="" class="bill_off"></a></li>   <li><a href="" class="report_off"></a></li>   <li><a href="" class="information_off"></a></li>   <li><a href="" class="password_off"></a></li></ul>

配置文件:web.xml

<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">  <display-name>netctoss</display-name>  <welcome-file-list>    <welcome-file>index.html</welcome-file>    <welcome-file>index.htm</welcome-file>    <welcome-file>index.jsp</welcome-file>    <welcome-file>default.html</welcome-file>    <welcome-file>default.htm</welcome-file>    <welcome-file>default.jsp</welcome-file>  </welcome-file-list>    <servlet>    <servlet-name>main</servlet-name>    <servlet-class>web.MainServlet</servlet-class>  </servlet>  <servlet-mapping>    <servlet-name>main</servlet-name>    <url-pattern>*.do</url-pattern>  </servlet-mapping>    <!-- 每页显示行数5行 -->  <context-param>    <param-name>size</param-name>    <param-value>5</param-value>  </context-param>    <!--   配置错误页面 (要采用绝对路径)  1.tomcat是所有服务端代码调用的入口,他在调用时会尝试捕获异常  2.默认的它捕获到异常时会自动转发到对应的错误页面,例如404.html/500.html/  3.我们可以通过配置改变该默认行为,捕获异常时跳转到响应的页面,但解决不了问题,只能让用户体验好一些  4.声明错误页面时需要写绝对路径,但由于是转发过去,只能访问此项目内部的资源,所以tomcat会自动        帮我们加上项目名,自己就别写项目名  -->  <!-- 1.通过异常类型进行配置 -->  <error-page>    <exception-type>java.lang.Exception</exception-type>    <location>/WEB-INF/error.jsp</location>  </error-page>    <!-- 2.通过异常编号(404.405.500)进行配置 -->  <!--   <error-page>    <error-code></error-code>    <location></location>  </error-page>   -->      <!-- 登陆检查过滤器 -->   <filter>     <filter-name>login</filter-name>     <filter-class>web.LoginFilter</filter-class>   </filter>   <filter-mapping>     <filter-name>login</filter-name>     <url-pattern>*.do</url-pattern>   </filter-mapping>   </web-app>


原创粉丝点击