Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<mvc:interceptors> not working #2

Open
user20161119 opened this issue Oct 17, 2013 · 2 comments
Open

<mvc:interceptors> not working #2

user20161119 opened this issue Oct 17, 2013 · 2 comments

Comments

@user20161119
Copy link

i use the follow mvc config,but the mvc:interceptores not working,i google it,and most answers told that not use

 <mvc:annotation-driven /> 

i want to the internal reason,thanks

<context:component-scan base-package="com">
        <context:include-filter type="annotation"
            expression="org.springframework.stereotype.Controller" />
    </context:component-scan>

    <mvc:interceptors>
       <mvc:interceptor>
          <mvc:mapping path="/"/>
          <bean id="ucInterceptor" class="com.cyberdis.hands.component.uc.UCInterceptor"/>
       </mvc:interceptor>
    </mvc:interceptors>
    <!-- Enables the Spring MVC @Controller programming model -->
     <mvc:annotation-driven /> 


    <!-- @ResponseBody -->
    <bean
        class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
        <property name="messageConverters">
            <list>
                <bean
                    class="org.springframework.http.converter.StringHttpMessageConverter">
                    <property name="supportedMediaTypes">
                        <list>
                            <value>text/plain;charset=UTF-8</value>
                        </list>
                    </property>
                </bean>
            </list>
        </property>
    </bean>

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>
    <bean class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean" id="cnManager">
        <property name="favorPathExtension" value="true"/>
        <property name="ignoreAcceptHeader" value="true" />
        <property name="defaultContentType" value="text/html" />
        <property name="mediaTypes">
            <map>
                <entry key="html" value="text/html" />
                <entry key="json" value="application/json" />
                <entry key="xml" value="application/xml" />
                <entry key="msg" value="application/message" />
            </map>
        </property>
    </bean>
@user20161119
Copy link
Author

and i can not useing @responsebody annotation to convert object to json,i add jackjson jar in my classpath like in your pom.xml

@RequestMapping(value="test",produces={"application/json"})
    public @ResponseBody FBUser json(HttpServletRequest request,HttpServletResponse response){
        /*
        CustomerUser cusUser = null;

        if(cusUser == null){
            cusUser = new CustomerUser();
            cusUser.setStrCusrName("hailiang");
        }
        request.setAttribute("userInfo", cusUser);*/
        FBUser fu = new FBUser();
        fu.setUserEmail("abc");
        return fu;
    }

@user20161119
Copy link
Author

i use:

<property name="favorPathExtension" value="false"/>

and your demo project is not working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant