当前位置: 代码迷 >> Java Web开发 >> struts-2.3.16整合spring4.0.3报错!麻烦大家帮忙看看
  详细解决方案

struts-2.3.16整合spring4.0.3报错!麻烦大家帮忙看看

热度:2785   发布时间:2016-04-10 22:35:25.0
struts-2.3.16整合spring4.0.3出错!麻烦大家帮忙看看
第一次提问,不太懂,抱歉,在线等,有什么需要提供的马上粘

login.jsp提交请求
<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>


LoginAction.java如下

//省略部分代码
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(
//省略部分代码

调试的时候在这一行报错:flag = loginService.login(accountId,request.getParameter("password"));

启动tomcat时有这一行信息:



配置文件
applicationContext.xml
<?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>
                <!--省略部分代码-->
</bean>


<!-- 配置SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="configLocation" value="classpath:hibernate.cfg.xml"/>
<!-- 指定关系映射文件 -->
<property name="mappingDirectoryLocations">
    <list>
        <value>classpath:com/onlinetest/yl/Hibernate/entity</value>
     </list>
</property>
</bean>
       <!--省略部分代码-->


<!-- 配置HibernateTemplateBean -->
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate4.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

<bean id="AccountDAO" class="com.onlinetest.yl.dao.impl.AccountDAOImpl">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>

<bean id="UserdataDAO" class="com.onlinetest.yl.dao.impl.UserdataDAOImpl">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>

<!--省略部分代码-->

<bean id="LoginService" class="com.onlinetest.yl.businessLogic.impl.LoginServiceImpl" scope="prototype" >
<property name="AccountDAO">
<ref bean="AccountDAO"/>
</property>
</bean>

<bean id="LoginAction" class="com.onlinetest.yl.action.LoginAction"
scope="prototype" >
  相关解决方案