凭海临风 2010-09-26 08:38
浏览 536
已采纳

struts2整合spring struts.xml中的action的class 总说找不到

struts2版本 2.0.14
spring版本 2.5
tomcat 版本6.0.14
IDE:myeclipse6.0
struts2与spring整合中 出现问题
LoginAction.java
[code="java"]

public class LoginAction extends ActionSupport {
private String username;
private String password;
private LoginService loginService;
public LoginService getLoginService() {
return loginService;
}
public void setLoginService(LoginService loginService) {
this.loginService = loginService;
}

public String execute()throws Exception
{
    if (this.getLoginService().isLogin(username,password)) {
        return "success";
    }
    return "input";
}
public String getUsername() {
    return username;
}
public void setUsername(String username) {
    this.username = username;
}
public String getPassword() {
    return password;
}
public void setPassword(String password) {
    this.password = password;
}

}

[/code]

loginServiceImpl
[code="java"]

public class LoginServiceImpl implements LoginService {

public boolean isLogin(String username,String password) {
    if ("admin".equals(username)&&"123".equals(password)) {
        return true;
    }
    return false;
}

}

[/code]
applicationContext.xml
[code="java"]
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<bean id="loginService"
    class="com.intelsrc.service.impl.LoginServiceImpl">
</bean>

<bean id="loginAction" class="com.intelsrc.action.LoginAction"
    scope="prototype">
    <property name="loginService">
        <ref bean="loginService" />
    </property>
</bean>

[/code]

struts.xml
[code="java"]


<!-- -->


/error.jsp
/result.jsp
/login.jsp


[/code]

web.xml
[code="java"]

org.springframework.web.context.ContextLoaderListener


contextConfigLocation
/WEB-INF/applicationContext*.xml,classpath*:applicationContext-*.xml


struts2
org.apache.struts2.dispatcher.FilterDispatcher


struts2
/*

[/code]

jar包

[img]http://dl.iteye.com/upload/attachment/316595/963d104e-df0d-32a7-991c-671253f15dc0.jpg[/img]
运行后出现如下错误信息

[img]http://dl.iteye.com/upload/attachment/316608/0f1bea96-6583-3426-a3b2-a05aecad6bf4.jpg[/img]

大家帮忙看看是什么问题?

  • 写回答

2条回答 默认 最新

  • songfantasy 2010-09-26 08:57
    关注

    [quote]


    contextConfigLocation

    /WEB-INF/applicationContext*.xml,classpath*:applicationContext-*.xml


    [/quote]

    把这个放在
    [quote]

    org.springframework.web.context.ContextLoaderListener

    [/quote]
    前面

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序