1

専用 URI をマップするコントローラー Bean を作成します。

web.xmlファイル:

    <!-- Spring MVC Servlet (that will route HTTP requests to BlazeDS) -->
 <servlet>
  <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>/WEB-INF/spring-main-config.xml</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
 </servlet>

 <!-- We are only using BlazeDS AMF channels to communicate with FlexClient, so let's map URLs accordingly. -->
 <servlet-mapping>
  <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
  <url-pattern>/messagebroker/*</url-pattern>        
 </servlet-mapping>   

        <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-filter-config.xml</param-value>
        </context-param>

        <listener>
               <listener-class>
                org.springframework.web.context.ContextLoaderListener
               </listener-class>
        </listener>

spring-main-config.xmlファイル:

 <!-- Import configuration base -->
 <import resource="spring-base-config.xml"/>  

 <!-- Flex integration within Spring. -->
 <flex:message-broker services-config-path="/WEB-INF/flex-services-config.xml">
  <flex:remoting-service />
 </flex:message-broker>

 <!-- Session-scoped bean for User Info -->
 <bean class="com.sharehunter.businessservices.common.UserSessionInfo" scope="session">
  <aop:scoped-proxy proxy-target-class="false"/>
 </bean>    

spring-filter-config.xmlファイル:

    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
  <property name="mappings">
   <value>
   /fbauth=myController
   </value>
  </property>
 </bean>

 <bean id="myController" 
  class="myapp.controller.myController" />

私のBeanコントローラーファイル:

package myapp.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

    public class MyController extends AbstractController{

    @Autowired
    UserSesson userSession;

    @Autowired
    BusinessLogger logger;

 @Override
 protected ModelAndView handleRequestInternal(HttpServletRequest request,
   HttpServletResponse response) throws Exception {

  // TO DO - Facebook authentication
  return null;
 }
 }

私の問題:コントローラー Bean 内のすべての Autowired Bean は、既に null で等しいです。構成のどこに問題があるのか​​ わかりません...

ご助力ありがとうございます !

アンソニー

4

2 に答える 2

2

2 つの異なる contextx が定義されています (spring-filter-config.xmlspring-main-config.xml) が、おそらく 1 つしかないはずです。<context:annotation-driven/>は でのみ定義されspring-main-config.xml、 では定義されないspring-filter-config.xmlため、 で定義された Bean はオートワイヤーされspring-filter-config.xmlません。

でコントローラを定義していますがspring-filter-config.xml、コントローラはServiceDispatcherServlet. の内容を に移動してから、 を削除する必要がありspring-filter-config.xmlますspring-main-config.xmlContextLoaderListenerこれを適切に使用していないようです。

于 2010-09-06T11:59:23.377 に答える
0

Beanマッピングはどこにありますか?

そこにあるxmlファイルに言及すると、@ Autowiredは、デフォルトでどのBeanクラスが呼び出されるかを識別します...

于 2011-11-09T05:14:18.197 に答える