07hnust

导航

03 2012 档案

访问资源包的方式
摘要:jsp页面:1、jsp页面中引入标签库<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>2、Struts标签<bean:message key="login.jsp.label.username" />Action类://获取请求的local信息Locale locale = getLocale(request);//获取资源包MessageResource message = getResource(request);//从资源包中得到信息文本并 阅读全文

posted @ 2012-03-16 12:00 07hnust 阅读(176) 评论(0) 推荐(0)

htmlerros标签应用
摘要:<bean:message key="login.jsp.page.heading" /> <html:errors /><!--返回所有的错误!--> <html:form action="login.do"> <table> <tr> <td><bean:message key="login.jsp.label.username" /> </td> <td><html:text property=" 阅读全文

posted @ 2012-03-16 11:34 07hnust 阅读(157) 评论(0) 推荐(0)

DispatchAction类一个Action中包含多个业务处理<测试通过>
摘要:前台页面:DispatchActionTest.jsp<%@ page language="java" pageEncoding="UTF-8"%><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%><%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%><html:html& 阅读全文

posted @ 2012-03-16 11:28 07hnust 阅读(212) 评论(0) 推荐(0)

监视在线用户数<测试通过>
摘要:创建监听器:OnlineListener.javapackage com.Sourcecode.SessionFactory;import javax.servlet.http.HttpSessionEvent;import javax.servlet.http.HttpSessionListener;public class OnlineListener implements HttpSessionListener{private int count;public OnlineListener(){count = 0;}public void sessionCreated(HttpSessi 阅读全文

posted @ 2012-03-15 10:48 07hnust 阅读(177) 评论(0) 推荐(0)

使用JDBC添加数据和查询数据<测试通过>
摘要:1、连接数据库工具类package com.JDBC.ConnectionDB;import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;public class ConnectionDB{public static Connection getConnection() throws ClassNotFoundException{String url = "jdbc:sqlserver://localhost:1433;databasename=Student" 阅读全文

posted @ 2012-03-14 17:19 07hnust 阅读(430) 评论(0) 推荐(0)

常用数据库的JDBC连接代码
摘要://oracle数据库Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();String url="jdbc:oracle:thin:@localhost:1521:xx";String user="user";String password="psw";Connection conn=DriverManager.getConnection(url,user,password);//DB2数据库Class.forName("com.i 阅读全文

posted @ 2012-03-14 15:14 07hnust 阅读(203) 评论(0) 推荐(0)

JDBC连接数据库与操作数据
摘要://定义链接数据库的URL,数据库名称为xxString url="jdbc:microsoft:sqlserver://localhost:8080;databaseName=xx";//Sqlserver//定义登陆数据库的用户名称saString user="sa";//定义登录数据库的用户密码saString psw="sa"//定义获取连接的对象Connection conn= null;//获取数据库驱动Class.forName("com.microsoft.jdbc.sqlserver.SQL ServerD 阅读全文

posted @ 2012-03-14 14:53 07hnust 阅读(102) 评论(0) 推荐(0)

退出系统须采取的方法
摘要:退出系统的jsp:<%@ page language="java" pageEncoding="UTF-8"%><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%><%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%><%@ taglib uri="http://s 阅读全文

posted @ 2012-03-09 15:13 07hnust 阅读(250) 评论(0) 推荐(0)

用户必须先登录,否则无法完成任何操作
摘要:登录jsp页面:<%@ page language="java" pageEncoding="UTF-8"%><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%><%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%><html><head><title 阅读全文

posted @ 2012-03-09 15:06 07hnust 阅读(426) 评论(0) 推荐(0)

date String Timestamp 的相互转化
摘要:用Timestamp来记录日期时间还是很方便的,但有时候显示的时候是不需要小数位后面的毫秒的,这样就需要在转换为String时重新定义格式。 Timestamp转化为String:SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义格式,不显示毫秒Timestamp now = new Timestamp(System.currentTimeMillis());//获取系统当前时间String str = df.format(now); String转化为Timestamp:Simple 阅读全文

posted @ 2012-03-07 12:18 07hnust 阅读(347) 评论(0) 推荐(0)

Hibernate+sqlserver向数据库中添加日期类型
摘要:从数据库中读取日期值:public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response){ TimeForm timeForm = (TimeForm) form;// TODO Auto-generated method stub String id = timeForm.getTimeid(); Configuration config = new Configuration().configure()... 阅读全文

posted @ 2012-03-07 12:16 07hnust 阅读(969) 评论(0) 推荐(0)