日期:2014-05-17 浏览次数:20686 次
<form name="user" action="${pageContext.request.contextPath}/login.action"
onsubmit="return validate_form(this)" method="post">
<div id="inputAcount">账户:<input type="text" name="accountId" value="${username}" /> </div>
<div id="inputPsw">密码:<input type="password" name="password"/></div>
<div id="submit"><input type="submit" value=确定><input type="reset" value=重置> </div>
</form>
//省略部分代码
public String loginVerify(){
int flag;
String result;
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession(false);
Integer accountId = Integer.valueOf(request.getParameter("accountId"));
//login()验证用户:返回1,账号错误;返回2,账号密码正确;返回3,密码错误;
flag = loginService.login(accountId,request.getParameter("password"));
switch(flag)
{
case 1:
result = "ACCOUNTWRONG";
request.setAttribute("msg", "账号错误");
break;
case 2:
this.setUserdata(userdataDAO.queryByAccountId(accountId));
session.setAttribute(
//省略部分代码
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
<!-- 配置数据源 -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
&nb