需要有关dispatcher servlet xml文件的帮助吗

需要有关dispatcher servlet xml文件的帮助吗,xml,spring,servlets,spring-mvc,Xml,Spring,Servlets,Spring Mvc,我正在尝试这个dispather servlet xml文件 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframewo

我正在尝试这个dispather servlet xml文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
       xmlns:p="http://www.springframework.org/schema/p">
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/jsp/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>
    <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="interceptors">
            <list>
                <ref local="localeChangeInterceptor"/>
            </list>
        </property>
        <property name="urlMap">
            <map>
                <entry key="/hello.html">
                    <ref bean="helloController"/>
                </entry>
            </map>
        </property>
    </bean>
    <bean id="helloController" class="net.roseindia.web.HelloWorldController"></bean>
    <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
        <property name="paramName" value="hl"/>
    </bean>
    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/>
</beans>

弹簧参考中描述了这些部件的功能,请参阅

  • LocaleResolver
    确定用户的区域设置
  • LocaleChangeInterceptor
    允许用户手动更改其区域设置

请注意,Roseindia是一个很差的学习资源。而是参考Spring自己的文档/教程。我是否总是需要它,因为我已经阅读了许多其他未使用它的示例,所以示例在不使用它的情况下是否可以工作it@Name:如果要使用本地化,则需要它。
<property name="interceptors">
    <list>
        <ref local="localeChangeInterceptor"/>
    </list>
</property>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/>