刚刚整合框架 出现错误,我的代码如下
 index.jsp  <body>dfdq
    <s:form action="loginAction"  method="post">
    <s:textfield name="username" label="用户名"></s:textfield>
    <s:textfield name="password" label="密  码"></s:textfield>
    <s:submit value="登录"></s:submit>
    </s:form>
  </body>
web.xml
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  
  <context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
  </context-param>
  
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:applicationContext.xml</param-value>
  </context-param>
 
     <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
     <!-- Spring 字符集Filter -->
<filter>
<filter-name>setCharacterEncoding</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter> <filter-mapping>
<filter-name>setCharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

  
  <filter> 
       <filter-name>HibernateOpenSession</filter-name>    
       <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>  
       <init-param>  
           <param-name>sessionFactoryBeanName</param-name>  
           <param-value>MySessionFactory</param-value>
       </init-param>
</filter>      <filter-mapping>  
     <filter-name>HibernateOpenSession</filter-name>  
            <url-pattern>/*</url-pattern>  
    </filter-mapping>   
[b]struts.xml[/b]
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="true" />
   <!-- 开发模式下使用,这样可以打印出更详细的错误信息 -->  
    <constant name="struts.devMode" value="true" />  
    <constant name="struts.objectFactory" value="spring" />      <package name="default"  extends="struts-default">
        <default-action-ref name="index" />
        <action name="loginAction" class="LoginAction">
            <result name="success">/success.jsp</result>
            <result name="error">/error.jsp</result>
        </action>
    </package>applicationContext.xml
 <!-- 配置sessionFactory -->
  <bean id="MySessionFactory"  
  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">  
   <property name="configLocation">  
    <value>classpath:hibernate.cfg.xml</value>  
     </property>
   </bean>
   
<!-- 配置translation管理 -->
 <bean id="transactionManager"  
           class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
            <property name="sessionFactory"><!--  
                 <ref local="MySessionFactory" />  
                 --><ref bean="MySessionFactory"/>
            </property>  
     </bean>  
<!-- 配置事物传播特性  -->
 <tx:advice id="txAdvice" transaction-manager="transactionManager">  
         <tx:attributes>  
             <tx:method name="add*" propagation="REQUIRED"/>  
             <tx:method name="delete*" propagation="REQUIRED"/>  
             <tx:method name="update*" propagation="REQUIRED"/>  
             <tx:method name="*" read-only="true"/>  
         </tx:attributes>  
     </tx:advice> 
     
     <aop:config>  
         <aop:pointcut id="targetMethod" expression="execution(* com.endual.service.*.*(..))"/>  
         <aop:advisor advice-ref="txAdvice" pointcut-ref="targetMethod"/>  
     </aop:config>   
<bean id="LoginServiceImpl" class="com.endual.service.LoginServiceImpl"/>

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

</bean>
   LoginAction类   public class LoginAction extends ActionSupport        private LoginServic loginService;
private String username;
private String password;
public LoginServic getLoginService() {
return loginService;
}
public void setLoginService(LoginServic loginService) {
this.loginService = loginService;
}
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;
}

public String execute() throws Exception {
System.out.println(username);
System.out.println(password);
if (loginService.isLogin(username, password)) {
return "success";
}
return "error";
}
LoginServic 接口public interface LoginServic {
  
public boolean isLogin(String username,String password);

}LoginServiceImpl实现接口public class LoginServiceImpl implements LoginServic {
public boolean isLogin(String username, String password) {

if("admin".equals(username) && "admin".equals(password)){
System.out.println("我进入到spring");
   return true;
      }
return false;   }
}
还有一个User类和一个hibernate的数据源配置文件,这个是测试数据库的,可是不能用。真是郁闷透顶啊type Exception reportmessagedescription The server encountered an internal error () that prevented it from fulfilling this request.exceptionorg.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'MySessionFactory' is defined
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:387)
org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:971)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:168)
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:884)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:243)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:227)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:171)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88)
这个是错误提示,有时候改下 web.xml以后,会出现LoginAction不能实例化
删掉这个
  <filter> 
       <filter-name>HibernateOpenSession</filter-name>    
       <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>  
       <init-param>  
           <param-name>sessionFactoryBeanName</param-name>  
           <param-value>MySessionFactory</param-value>
       </init-param>
</filter> 
我强烈怀疑这错了。不知道怎么弄,我第一次搞整合。两两整合弄了,何在一起,在web,xml中写配置居然错误,真是难过啊