j2ee实现开放基金交易平台(不断更新)

来源:互联网 发布:必备厨具知乎 编辑:程序博客网 时间:2024/04/30 17:20

有道笔记地址:http://note.youdao.com/share/?id=888bd1117e3c127d9acd04ad81f26f57&type=note

//项目要求
//系统界面.doc 系统设计说明书.doc 系统需求说明书.doc
//1.数据库导入
        使用了wamp,直接通过phpadmin进行数据库导入db.sql


//2.模板查找
    为了更快的进行编码,对于界面直接采用网上的做好的模板.
//登录模板
    login模板.rar
//后台模板
    自己找到也比较蛋疼,这边就不发了.自己百度找好看的吧,要不然就自己随便写一个吧


//开始编码
    //包目录--基本实现MVC模式
        src
            -com.cjp.controller//serverlet控制类
            -com.cjp.model//javabean模型类,用来实现数据库连接等操作
            -com.cjp.util//存放一些工具类,如一些过滤器


//login页编码
    -com.cjp.controller
        -LoginController.java//继承httpservlet,重写service方法
            -通过request获得表单传递参数
            -调用javabean,与数据库进行比较
            -如果存在就跳转到后台,不存在提示错误.
        -servlet的xml配置
            在web.xml中进行配置
                <servlet>
                     <!-- servlet名 -->
                     <servlet-name>LoginController</servlet-name>
                     <servlet-class>com.cjp.logic.LoginController</servlet-class>
                </servlet>
                <!--servlet映射-->
                <servlet-mapping>
                     <servlet-name>LoginController</servlet-name>
                       <!--转发名(格式)-->
                     <url-pattern>/login.do</url-pattern>
                </servlet-mapping>
                
    -com.cjp.Model
        -Connect.java//javabean类用来实现数据库连接


//index.jsp后台页的编写
Admin.rar (包含login页)
将html格式改成jsp格式.
需注意,要在jsp文件开头添加一些基本元素
..url路径等
//对象域
    在com.cjp.domain中增加如下几个对象类
            -fund//资金账户
            -financial//用户资金
            -client//用户
   根据数据库 建立相应的对象属性
//数据库操作
    在com.cjp.util包中新建一个connectController接口和一个connectControllerImpl用来实现对数据库的操作.
     主要方法有几类
                -数据库连接connect()
                -数据库更新update()
                -增加用户add_client()
                -增加资金账户add_fund()
                -增加资金 add_financial()
    在 com.cjp.dao中新建一个pagehelper的接口和pagehelperimpl类用来实现对于数据库表的的封装
               方法返回结果为List<object>
//数据的表格查询显示
1.从数据库将表提出到一个数组
2.用setattribute存入
3.在jsp页面通过for语句循环显示
//备注信息: 表单查询显示eg
public void doGet(HttpServletRequest request,HttpServletResponse response)
                   throws ServletException,IOException{
    
    String sql = "select * from admin";
    Collection retValue = new ArrayList();
SqlBean app = new SqlBean();

try{
ResultSet rs = app.executeQuery(sql);
while(rs.next())
{
//user bean of teacher
TeacherBean tb = new TeacherBean();
tb.setName(rs.getString("userName"));
tb.setSex(rs.getString("userPwd"));
retValue.add(tb);
}
rs.close();
app.dbClose();

}
catch(SQLException e){}
request.setAttribute("teacher",retValue);
String toPath = "/SLT/teacher.jsp";
RequestDispatcher rd = request.getRequestDispatcher(toPath);
rd.forward(request,response);
  }
-----
在jsp页面接受
 ArrayList al = (ArrayList)request.getAttribute("teacher") ;
  for(int i = 0 ; i < al.size() ; i ++)
  {
   mb = (mvc.TeacherBean)al.get(i);
   out.println(mb.getName());
   out.println("<br>");
  }
%> 
//java 时间格式化

JAVA格式化时间日期

import java.util.Date;
import java.text.DateFormat;


/**
* 格式化时间类
* DateFormat.FULL = 0
* DateFormat.DEFAULT = 2
* DateFormat.LONG = 1
* DateFormat.MEDIUM = 2
* DateFormat.SHORT = 3
* @author    Michael 
* @version   1.0, 2007/03/09
*/

public class Test{
    public static void main(String []args){
        Date d = new Date();
        String s;
          
        /** Date类的格式: Sat Apr 16 13:17:29 CST 2006 */
        System.out.println(d);
          
        System.out.println("******************************************");   
        
        /** getDateInstance() */ 
        /** 输出格式: 2006-4-16 */
        s = DateFormat.getDateInstance().format(d);
        System.out.println(s);
        
        /** 输出格式: 2006-4-16 */
        s = DateFormat.getDateInstance(DateFormat.DEFAULT).format(d);
        System.out.println(s);
        
        /** 输出格式: 2006年4月16日 星期六 */
        s = DateFormat.getDateInstance(DateFormat.FULL).format(d);
        System.out.println(s);
        
        /** 输出格式: 2006-4-16 */
        s = DateFormat.getDateInstance(DateFormat.MEDIUM).format(d);
        System.out.println(s);
        
        /** 输出格式: 06-4-16 */
        s = DateFormat.getDateInstance(DateFormat.SHORT).format(d);
        System.out.println(s);
        
        /** 输出格式: 2006-01-01 00:00:00 */
        java.text.DateFormat format1 = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        s = format1.format(new Date());
        System.out.println(s);
        
        /** 输出格式: 2006-01-01 00:00:00 */
        System.out.println((new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss")).format(new Date()));
        
        /** 输出格式: 20060101000000***/
        java.text.DateFormat format2 = new java.text.SimpleDateFormat("yyyyMMddhhmmss");
        s = format2.format(new Date());
        System.out.println(s); 
    }
}   

//备注sql语句
update xx from xx set xx= xx
delete xx from xx where xx=xx

0 0
原创粉丝点击