现在的位置: 首页 > 综合 > 正文

使用梦想年华新闻的总结五大点

2013年08月30日 ⁄ 综合 ⁄ 共 6248字 ⁄ 字号 评论关闭

使用梦想年华新闻的总结五大点
一为空判断  1<link href="../admin/css/bodystyle.css" rel="stylesheet" type="text/css">
 2//为空判断
String [] s=new String [1];
String [] sa1 = new String [1];
String [] sa2 = new String [1];
s[0] = request.getParameter("item");
sa1[0] = s[0];
sa2[0] = ""金马奖最佳影片调查"投票答案不能为空! ";
String sOK = Fun.CheckDate(sa1,sa2);
if (!sOK.equals("Yes"))
{
 out.print(Fun.OutError(sOK));
 return;
}
 //

二分页
分页
1.onChange=/"MM_jumpMenu('self',this,0)
   function MM_jumpMenu(targ,selObj,restore){   //v3.0
   eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
   if (restore) selObj.selectedIndex=0;
 }

<script src="../admin/js/post.js"></script>
2.
int intPage=1;
   int intPageSize=10;
   String strPage=request.getParameter("intPage");
   String sPage=request.getContextPath()+request.getServletPath()+"?";
   // if(strPage!=null){
    intPage = Fun.StrToInt(strPage);
   // }
  //  System.out.print("当前页是第"+intPage+"页");
    if (intPage==0) intPage=1;
    sPage = Fun.CheckReplace(sPage);
    //System.out.println("跳转页网址是"+sPage);

 rs.absolute((intPage-1) * intPageSize+1);
 int j = 0;
 while(j < intPageSize && !rs.isAfterLast())

    rs.getString(1);....
    rs.next();
 j++;
  }
  
   out.println(Fun.Page(sPage,rs,intPage,intPageSize));
 db.closeConnection();

3参考houtai.jsp
  <head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<link href="../admin/css/bodystyle.css" rel="stylesheet" type="text/css">
<title></title>
</head>

  <head>
   <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
<script type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
 function send(id)
 {
 window.location.href="sel_do.jsp?id="+id;}
//-->
</script>
<link href="css/bodystyle.css" rel="stylesheet" type="text/css">
  </head>
onsubmit="return Mycheck()"
  <script language="javascript" type="">
function Mycheck(){
if (form1.topic.value=="")
{ alert("请输入投票主题!");return  false;}
form1.submit();
}
</script>
  
   try{DBConnection DBConn = new DBConnection();
    Connection con = DBConn.getConn();
   
  } catch (Exception ex) {
   System.out.println("数据库加载失败");
  }
 }

 // 创建数据库连接
 public boolean creatConnection() {
  try {
    Statement stmt = con.createStatement(1004,1007);
   con.setAutoCommit(true);

  } catch (SQLException e) {
   System.out.println(e.getMessage());
   System.out.println("creatConnectionError!");
  }
  return true;
 }

版面要注意head的定义
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<link href="bodystyle.css" rel="stylesheet" type="text/css">
<title></title>
</head>
bodystyle.css
/* CSS Document */

@charset "GBK";

/* 链接颜色 */
A:link {
 COLOR: #457FFC; TEXT-DECORATION: none; font-family: "宋体"; font-size: 9pt
}
A:visited {
 COLOR: #457FFC; TEXT-DECORATION: none; font-family: "宋体"; font-size: 9pt
}
A:active {
 COLOR: #FF0000; TEXT-DECORATION: none; font-family: "宋体"; font-size: 9pt
}
A:hover {
 COLOR: #6600FF; TEXT-DECORATION: underline; font-family: "宋体"; font-size: 9pt
}

.news a:link{ COLOR:#555555; TEXT-DECORATION: none; font-family: "宋体"; font-size: 12px}
.news a:visited{COLOR:#336699; TEXT-DECORATION: none; font-family: "宋体"; font-size: 12px}
.news a:hover{COLOR: #ff6600; TEXT-DECORATION: underline; font-family: "宋体"; font-

size:12px}
.news a:active{COLOR:#ff0000; TEXT-DECORATION: none; font-family: "宋体"; font-size: 12px}

/*页面属性*/
BODY {
 margin-top: 0px;
 margin-bottom: 0px;
 margin-left: 0px;
 margin-right: 0px;
 BACKGROUND:#DBE6FE;
 MARGIN: 0px;
 FONT: 9pt 宋体;
 SCROLLBAR-HIGHLIGHT-COLOR:#d6dff7;
 SCROLLBAR-ARROW-COLOR:#215dc6;
 SCROLLBAR-TRACK-COLOR:#d6dff7;
 SCROLLBAR-BASE-COLOR:#AEC6F0;
}

/*按钮属性*/
.button {
 BORDER-RIGHT: #457FFC 1px ridge;
 PADDING-RIGHT: 1px;
 BORDER-TOP: #ffffff 1px ridge;
 PADDING-LEFT: 1px;
 FONT-SIZE: 9pt;
 PADDING-BOTTOM: 1px;
 BORDER-LEFT: #ffffff 1px ridge;
 COLOR: #000000;
 PADDING-TOP: 1px;
 BORDER-BOTTOM: #457FFC 1px ridge;
 FONT-FAMILY: "宋体";
 HEIGHT: 20px;
 BACKGROUND-COLOR: #f1f1f1;
 cursor: hand;
}

/*文字属性*/
.chinese
{
    FONT-SIZE: 12px;
    FONT-FAMILY: "宋体";
 color:#333333;
}

/*标题属性*/
.title {
 font-size:12pt;
 font-family: "宋体";
 color:#457FFC;
 }
 
/*提示信息字体属性*/
.info1
{
 color:#FA605E;
    font-size:10pt;
}

/*表格属性*/
table {
 background-color:#DBE6FE;
 border-color:#457FFC;
 border-collapse:collapse;
 border-top-color:#457FFC;
 border-right-color:#457FFC;
 border-left-color:#457FFC;
 border-bottom-color:#457FFC;
 }
 
tr { border-color:#457FFC; }
td { border-color:#457FFC; } 

四session检测登陆
1.登陆成功后session.setAttribute("Login","Yes");
2.要检测登陆的页面。
<%@ include file="Session.jsp"%>
<%@ page language="java"  contentType="text/html; charset=GBK"%>
<%@ page import="dreamtime.dreamnews.*"%>
<%
 Function Function1 = new Function();
 boolean isLogin = Function1.StringToBoolean((String)session.getAttribute("Login"));
 if(!isLogin)
 {
  response.sendError(403,"禁止访问 您没有这个权限");
  return;
 }
%>
<head>

<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<link href="bodystyle.css" rel="stylesheet" type="text/css">
<title></title>
</head>


添加日志(所需源码function.java,DBoperation.java)
 // 添加到日志
 //s[0],操作的用户;
 //*       s[1],日志类型;
 //*     s[2],操作时间;
 //*         s[3],登录IP地址;
 //*         s[4],操作结果。
 String AdminName = (String)session.getAttribute("AdminName");
 String IP = request.getRemoteAddr(); 
 String NowTime = Fun.getDateStr();
 String [] sLog = new String[5];
 sLog[0]=AdminName;
 sLog[2]=NowTime;
 sLog[3]=IP;
 if(db.executeUpdate(sql2))
{
 // System.out.println("插入到vote表的语句是:"+sql2);
 
    sLog[1] = "添加投票主题["+topic+"]";
    sLog[4] = "Yes";
    Fun.AddLog(sLog);
    //添加日志,添加[topic]成功!
   }
   else
   { sLog[1] = "添加新的链接名["+topic+"]操作失败";
     sLog[4] = "No";
  Fun.AddLog(sLog);
     out.print(Fun.OutError("添加新的链接名操作出错,请核对你的输入!"));
    // return;
   }

用法
1.log表(oracle数据库)
logid number(10)
user  varchar2(32)
logtype varchar2(100)
logtime  date
ip  varchar2(15)
result  varchar2(3)      yes/no
2登陆页
if (login.LoginCheck(User,Pwd))
    {
 session.setAttribute("Login","Yes");
 session.setAttribute("AdminID",Integer.toString(login.AdminID));
 session.setAttribute("AdminType",Integer.toString(login.AdminType));
 session.setAttribute("AdminName",User);
 session.setAttribute("error","");
 out.println("<SCRIPT LANGUAGE='JavaScript'>alert('登成功!');
        location.href='Admin_Main.jsp';</SCRIPT>");
 return;
    }
http://download.csdn.net/source/358981

抱歉!评论已关闭.