首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • 高分求一个比较简单的有关JSP代码 [已结贴,结贴人:skya1216]
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-24 02:36:21 楼主
    高分求一个比较简单的代码:
    一个系统,有个“公告”(pcard)模块,数据库里,每个公告表(表名:tb_pcard)都有个过期时间(toTime,是String型的),要求每次登陆时:取本地时间(localTime)与toTime比较,如果localTime比toTime小3,就弹出窗口提示:“你有公告要过期!”
    这是简单的,麻烦点:取出要过期的公告名字(pcard_subject),提示消息为:“公告pcard_subject还有?过期!”
    下面是登陆页面的代码(JSP):
    还需要其他什么,可以说出来,谢谢!
    <%@ page contentType="text/html; charset=gb2312"%>
    <%@ taglib uri="struts-html" prefix="html" %>
    <%@ taglib uri="struts-bean" prefix="bean" %>
    <%@ taglib uri="struts-logic" prefix="logic" %>
    <%
    String contentPath=request.getContextPath();
    %>
    <html>
    <head>
    <html:base/>

    <link href=" <%=contentPath%>/css/style.css" type="text/css" rel="stylesheet">
    <title>用户登录 </title>
    </head>

    <body style="margin-top:100" bgcolor="skyblue" >
    <center>
      <table  width="423" height="253"  border="0" cellpadding="0" cellspacing="0" bordercolor=black bordercolorlight=black bordercolordark=white background="image/logon.jpg">
        <tr>
          <td height="70" colspan="2">&nbsp; </td>
        </tr>
        <tr>
          <td>&nbsp; </td>
          <td height="30" colspan="1" align="left" valign="middle"> <nobr>&nbsp; <html:errors/> </nobr> </td>
        </tr>
        <html:form action="/user/logon" focus="username">
        <tr>
          <td width="30%" height="20" align="right" valign="middle"> <bean:message key="office.logon.username.title"/>&nbsp; </td>
          <td width="70%" height="20" valign="top"> <html:text property="username" size="35" style="border:1 solid"/> </td>
        </tr>
        <tr>
          <td height="20" align="right" valign="middle"> <bean:message key="office.logon.password.title"/>&nbsp; </td>
          <td height="20" valign="top"> <html:password property="userpassword" size="35" style="border:1 solid" redisplay="false"/> </td>
        </tr>
        <tr align="center">
          <td height="40" colspan="2" valign="top">
          <html:submit value="登录"/>
          <html:reset value="重置"/>
          </td>
        </tr>
        </html:form>
      </table>
    </center>
    </body>
    </html>

    100  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-24 05:18:191楼 得分:40
    很简单啊,
    1.根据session取到当前用户的名称
    2.取到当前时间
    3.用if比较是否它们两个的差大于三,
      如果大于就用window.open打开啊,代码是:
      <script LANGUAGE="JavaScript">

      <!--

      window.open ("ad.htm", "newwindow", "height=250, width=300, top=100px,left=100px,toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no") //写成一行

     //-->

    </script>
    打开的这个窗口里面自己写要弹出的内容啊
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-24 05:33:482楼 得分:30
    select * from tb_pcard where Datediff(getdate(),toTime) between 0 and 3

    1 其中的datediff 根据不同的数据库,写法不同,有些还需要进行字段类型转换,因为你的 toTime是字符串的
    2 getdate 也需要根据数据库不同进行调整


    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-24 09:38:443楼 得分:30
    select * from tb_pcard where Datediff(getdate(),toTime) > 3
    1 其中的datediff 根据不同的数据库,写法不同,有些还需要进行字段类型转换,因为你的 toTime是字符串的
    2 getdate 也需要根据数据库不同进行调整
    哈哈
    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    北京创新乐知广告有限公司 版权所有 京 ICP 证 070598 号
    世纪乐知(北京)网络技术有限公司 提供技术支持
    Copyright © 2000-2008, CSDN.NET, All Rights Reserved