凭海临风 2010-09-26 00: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;
}

  1. public String execute()throws Exception
  2. {
  3. if (this.getLoginService().isLogin(username,password)) {
  4. return "success";
  5. }
  6. return "input";
  7. }
  8. public String getUsername() {
  9. return username;
  10. }
  11. public void setUsername(String username) {
  12. this.username = username;
  13. }
  14. public String getPassword() {
  15. return password;
  16. }
  17. public void setPassword(String password) {
  18. this.password = password;
  19. }

}

[/code]

loginServiceImpl
[code="java"]

public class LoginServiceImpl implements LoginService {

  1. public boolean isLogin(String username,String password) {
  2. if ("admin".equals(username)&&"123".equals(password)) {
  3. return true;
  4. }
  5. return false;
  6. }

}

[/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">

  1. <bean id="loginService"
  2. class="com.intelsrc.service.impl.LoginServiceImpl">
  3. </bean>
  4. <bean id="loginAction" class="com.intelsrc.action.LoginAction"
  5. scope="prototype">
  6. <property name="loginService">
  7. <ref bean="loginService" />
  8. </property>
  9. </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 00:57
    关注

    [quote]


    contextConfigLocation

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


    [/quote]

    把这个放在
    [quote]

    org.springframework.web.context.ContextLoaderListener

    [/quote]
    前面

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部