凭海临风 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 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算