开发者

spring 3 mvc intercept all requests

Hi im wondering would it be possible to create global interceptor and set locale there.

I have urlrewrite rules to rewrite /fr/* to /*?siteLang=fr

I see examples how to set locale based on parameter but they all are the same and require me to use url mappings. Is it possible to do it globally so that locale interceptor gets called on each request no matter what contro开发者_如何转开发ller is it for?

<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
    <property name="paramName" value="siteLang"/>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="interceptors">
        <list>
            <ref bean="localeChangeInterceptor"/>
        </list>
    </property>
    <property name="mappings">
        <value>
        /*=dispatchController
        </value>
    </property>
</bean>

There is no such thing as dispatchController in my xml so i cant use it but idea would be to intercept everything (in whatever way).

i would basically like to have urls with locale at the beginning of uri followed by the application bit like /fr/user/details /de/products/hifi etc

different controllers using the same convention of rewriting url and never using siteLang for controller specific reasons.

Thanks


<mvc:interceptors>
    <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>
</mvc:interceptors>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜