spring mvc+dwr 1的一个奇怪的问题

最近在搞的一个应用,用spring 1的MVC+hibernate 3+DWR1的,结果发现个奇怪的问题.其中用DWR1的地方也就是
在用户注册的时候,判断这个用户是否存在,这个用DWR1去做的,代码如下
  dwr的配置
    

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN" "http://www.getahead.ltd.uk/dwr/dwr10.dtd">

<dwr>
 <allow>
  <convert converter="bean" match="liao.*"/>
  <create creator="spring" javascript="MemberManager">
          <param name="beanName" value="userFacade"/>
        </create>
 </allow>
</dwr>
   但运行的时候老说Dwr找不到userFacade这个方法,我再次检查了所有环节,根本没错,与以前的程序代码都是一样的,查了很久,最后终于给我发现问题了.
原来我的这个应用,将保存DAO和配置facade等的配置文件没有命名为applicationContext!,以mode-config.xml命明了,虽然我在WEB.XML中另外
指定了对应的新的名称,但估计DWR不收货!(起码是DWR1不收货,所以错了!),一般来说,应该这样的结构吧,建议
applicationContext.xml:存放DAO及facade模式配置的xml,比如
  

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN"
 "http://www.springframework.org/dtd/spring-beans.dtd">
 <beans>
    <!-- 要设定您的数据库相关消息 -->
   <!--  <bean name="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
    <property name="sessionFactory">
          <ref bean="mysessionFactory"/> 
            </property> 
         </bean>-->
    <bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName">
            <value>com.mysql.jdbc.Driver</value>
        </property>
        <property name="url">
            <value>jdbc:mysql://localhost:3306/springlover</value>
        </property>
        <property name="username">
            <value>root</value>
        </property>
        <property name="password">
            <value>2222</value>
        </property>
    </bean> 
 
    <bean id="mysessionFactory"
          class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
          destroy-method="close">
        <property name="dataSource">
            <ref bean="dataSource"/>
        </property>
        <property name="mappingResources">
          <list>
      <value>liao/domain/User.hbm.xml</value>
      <value>liao/domain/Photo.hbm.xml</value>
      <value>liao/domain/Comment.hbm.xml</value>
      <value>liao/domain/Admin.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQLDialect
                </prop>
            </props>
        </property>
    </bean>

            
    <bean id="userDao"
           class="liao.dao.hibernate.UserDAO">
        <property name="sessionFactory">
   <ref local="mysessionFactory" />
  </property>      
     </bean>

        <bean id="photoFacade" class="liao.domain.logic.impl.PhotoFacadeImpl">
  <property name="photoDao">
   <ref bean="photoDao"/>
  </property>
 </bean>
   </beans>
而要再搞个应用名-servlet.xml,比如springlover-servlet.xml,里面的是controller等的设置,如

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN"
 "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    <bean id="urlMapping"
          class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
           <property name="mappings">
            <props>
             <prop key="/login.do">loginController</prop>
                <prop key="/register.do">registerController</prop>
             <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="viewClass">
            <value>org.springframework.web.servlet.view.JstlView</value>
        </property>       
        <property name="prefix">
            <value>/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>
  
<bean id="voteController" class="liao.web.VoteController">
  <property name="photoFacade">
   <ref bean="photoFacade" />
  </property>
  <property name="successView">
   <value>/index</value>
  </property>
</bean>

</beans>

最后是web,xml
 

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
  version="2.4">
  <display-name>springlover</display-name>
 
 <context-param>
  <param-name>webAppRootKey</param-name>
  <param-value>springlover.root</param-value>
 </context-param>
    <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext.xml</param-value>
 </context-param>
       
        <context-param>
  <param-name>log4jConfigLocation</param-name>
  <param-value>/WEB-INF/log4j.properties</param-value>
 </context-param>

 <context-param>
  <param-name>log4jRefreshInterval</param-name>
  <param-value>60000</param-value>
 </context-param>
  <filter>
  <filter-name>encodingFilter</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>
 </filter>

 <filter-mapping>
  <filter-name>encodingFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping> 
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>

<listener>
  <listener-class>
   org.springframework.web.context.ContextLoaderListener
  </listener-class>
 </listener>
 <listener>
  <listener-class>
   org.springframework.web.util.Log4jConfigListener
  </listener-class>
 </listener>
    <servlet>
  <servlet-name>springlover</servlet-name>
  <servlet-class>
   org.springframework.web.servlet.DispatcherServlet
  </servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>
      <servlet-mapping>
  <servlet-name>springlover</servlet-name>
  <url-pattern>*.do</url-pattern>
 </servlet-mapping>
   <servlet>
  <servlet-name>dwr-invoker</servlet-name>
  <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
  <init-param>
   <param-name>debug</param-name>
   <param-value>true</param-value>
  </init-param>
   </servlet>

 <servlet-mapping>
  <servlet-name>dwr-invoker</servlet-name>
  <url-pattern>/dwr/*</url-pattern>
 </servlet-mapping>
        
      <!--<servlet>
        <servlet-name>img</servlet-name>
       <servlet-class>
         liao.util.AuthImg</servlet-class>
       </servlet>-->
      
    <!-- <servlet-mapping>
       <servlet-name>img</servlet-name>
       <url-pattern>/admin/verfiycode</url-pattern>
       </servlet-mapping>-->
      
 
   </web-app>


 

你可能感兴趣的:(spring,mvc,bean,servlet,DWR)