凭海临风 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条)

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格