JavaWeb课程设计 - 图文(4)

2019-08-20 20:22

4、登录模块

由于本系统用户角色只有一种,不存在跳转到不同页面的问题,处理相对简单一些,如果用户登录成功,则将用户信息放到session中,并将页面跳转到导航页面。

(1)登录页面控制模块ALogin相关代码如下:

public class ALogin {

public void doLogin ( Hashtable inputData, Hashtable outputData, HttpSession mySession ) throws Exception {

//获取输入信息

String sUsername = (String)inputData.get(\); String sPassword = (String)inputData.get(\);

//校验用户输入信息 LUser lUser = (LUser)GlobalObjectProvider.getLogicService(CommonConst.LOGIC_KEY_USER);

//如果对应的类没有的话,报错并返回login页面 if ( lUser == null ) {

16

throw new Exception(\发生了内部错误,请联系技术人员!\ ); }

//获取用户信息 User userInfo = lUser.getUserInfo( sUsername, sPassword ); if ( userInfo == null ) {

outputData.put( \, CommonConst.VIEWID_LOGIN ); outputData.put( \, \用户名密码检查失败!请重新输入。\ );

outputData.put( \, sUsername ); return; } else {

outputData.put( \, CommonConst.VIEWID_MENU);

//往session中设置用户信息

mySession.setAttribute( \, userInfo ); return; }

}

}

(2)登录效果图

5、页面导航设计

(1)页面位置信息和页面的pageid息息相关,考虑用一个全局变量来存这个信息,然后通过在共通文件中来访问这个全局变量来获取对应页面的名称。为了达到这个目的设置一个成员变量pageinfo和对应的设置方法init(),对应代码如下:

public static Hashtable pageInfos = new Hashtable();

//数据库相关常量 public static String DB_DRIVER_CLASSNAME \;

=

17

public static String DB_CONN_STRING = \;

//初始化

public static void init() {

pageInfos.put(\,\目录页面\); pageInfos.put(\,\客户资料 > 客户资料录入页面\); pageInfos.put(\,\客户资料 > 客户资料修改一览页面\); pageInfos.put(\,\客户资料 > 客户资料修改详细页面\); pageInfos.put(\,\客户资料 > 客户资料删除页面\); pageInfos.put(\,\客户来电 > 快速反应条件输入页面\); pageInfos.put(\,\客户来电 > 快速反应结果一览页面\); pageInfos.put(\,\客户来电 > 客户来电信息添加页面\); pageInfos.put(\,\客户来电 > 客户来电信息查找页面\); pageInfos.put(\,\客户来电 > 客户来电信息一览页面\); pageInfos.put(\,\客户来电 > 客户来电信息详细页面\); pageInfos.put(\,\客户回访 > 客户回访信息添加页面\); pageInfos.put(\,\客户回访 > 客户回访信息查找页面\); pageInfos.put(\,\客户回访 > 客户回访信息一览页面\); pageInfos.put(\,\客户回访 > 客户回访信息详细页面\); pageInfos.put(\,\客户重要信息提醒页面\); }

//获得页面信息

public static String getPageInfo( String sPageId ) {

return (String)pageInfos.get(sPageId);

}

(2)页面外观设计

为四个模块设计不同颜色风格的CSS代码

.tr_head1 {color: black; background-color:#aaccaa;} .tr_content1 {color: black; background-color:#eeffee; cursor:hand;}

.tr_head2 {color: black; background-color:#ccaaaa;} .tr_content2 {color: black; background-color:#ffeeee; cursor:hand;}

.tr_head3 {color: black; background-color:#aaaacc;} .tr_content3 {color: black; background-color:#eeeeff; cursor:hand;}

.tr_head4 {color: black; background-color:#ccccaa;} .tr_content4 {color: black; background-color:#ffffee;

18

cursor:hand;}

(3)导航页效果图

5、客户资料维护模块

(1)客户资料录入

单击导航页面链接进入客户资料录入页面。注意两个方面:一是页面对应的显示元素和输入元素的颜色和当前模块的颜色想吻合,而是在用户输入信息并单击“登录”按钮时,将客户信息登入数据库,然后页面直接转入修改一览。 页面控制类ACustomerAdd:

public class ACustomerAdd {

//追加一个客户

public void doRegister( Hashtable inputData, Hashtable outputData, HttpSession mySession ) throws Exception {

//首先获得要追加的客户详细信息

String sRealname = (String)inputData.get(\); String sSex = (String)inputData.get(\);

String sBirthday = (String)inputData.get(\);

19

String sPhone = (String)inputData.get(\);

String sCellphone = (String)inputData.get(\); String sAddress = (String)inputData.get(\); String sStartDate = (String)inputData.get(\); String sMemo = (String)inputData.get(\);

//生成一个Customer对象以调用

Customer customer = new Customer(); customer.setRealname( sRealname ); customer.setSex( sSex );

customer.setBirthday( sBirthday ); customer.setPhone( sPhone );

customer.setCellphone( sCellphone ); customer.setAddress( sAddress );

customer.setStartDate( sStartDate ); customer.setMemo( sMemo );

//调用对应的logic类 LCustomer lCustomer = (LCustomer)GlobalObjectProvider.getLogicService(CommonConst.LOGIC_KEY_CUSTOMER);

//添加对应的记录

lCustomer.addCustomer( customer );

//然后重新检索,并将页面迁移到一览页面

Vector vCustomers = lCustomer.getAllCustomer();

outputData.put( \, CommonConst.VIEWID_CUSTOMER_LIST); //往值域中设置当前位置信息

mySession.setAttribute(\, vCustomers ); outputData.put( \, new Integer(0) ); return; } }

效果图:

20


JavaWeb课程设计 - 图文(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:电子商务安全实验

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: