Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何动态映射SpringWebMVC路径?_Java_Spring Mvc_Path - Fatal编程技术网

Java 如何动态映射SpringWebMVC路径?

Java 如何动态映射SpringWebMVC路径?,java,spring-mvc,path,Java,Spring Mvc,Path,这是一个交叉柱。我也在春季论坛上发布了同样的问题 您好,我正在尝试执行数据库驱动的控制器映射,以便它们可以在运行时更改 到目前为止,我的情况如下 自定义处理程序适配器,可在以后进行优化 @Component public class DatabasePageUrlHandlerMapping extends AbstractUrlHandlerMapping implements PriorityOrdered { @Override protected Object get

这是一个交叉柱。我也在春季论坛上发布了同样的问题

您好,我正在尝试执行数据库驱动的控制器映射,以便它们可以在运行时更改

到目前为止,我的情况如下

自定义处理程序适配器,可在以后进行优化

@Component
public class DatabasePageUrlHandlerMapping extends AbstractUrlHandlerMapping implements PriorityOrdered {


    @Override
    protected Object getHandlerInternal(HttpServletRequest request)
            throws Exception {
        String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
        List<Page> pages = Page.findAllPages();
        for (Page page : pages) {
            if (lookupPath.equals(page.getSeoPath())) {
                Object handler = getApplicationContext().getBean("_pageViewController");
                return new HandlerExecutionChain(handler);
            }
        }
        return super.getHandlerInternal(request);
    }

}
我是否需要定义自定义注释处理程序

老实说,整个过程似乎比它应该做的更困难。我想要一个控制器来处理对外部定义的url路径的所有请求。这是绕过它的正确方式吗

如果可能的话,我还希望将匹配的对象传递到控制器中,而不是在控制器中进行新的查找。这将基本上形成我的视图模型

有没有关于如何让它工作的建议

编辑 为了记录在案,NPE在这里

    private boolean useTypeLevelMapping(HttpServletRequest request) {
        if (!hasTypeLevelMapping() || ObjectUtils.isEmpty(getTypeLevelMapping().value())) {
            return false;
        }
        return (Boolean) request.getAttribute(HandlerMapping.INTROSPECT_TYPE_LEVEL_MAPPING);
    }
另一次编辑 pom.xml中的版本号

<properties>
    <aspectj.version>1.6.12</aspectj.version>
    <java.version>6</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <roo.version>1.2.1.RELEASE</roo.version>
    <slf4j.version>1.6.4</slf4j.version>
    <spring.version>3.1.0.RELEASE</spring.version>
<spring-security.version>3.1.0.RELEASE</spring-security.version>
</properties>

1.6.12
6.
UTF-8
1.2.1.发布
1.6.4
3.1.0.1发布
3.1.0.1发布

我自己已经回答了下面的问题,但我仍然对人们参与讨论正确的解决方法感兴趣。

为了克服这个具体问题,现在让我推荐一种解决方法-

在内部创建自己的handlerAdapter,包括AnnotationMethodHandlerAdapter:

public DBAnnotationMethodHandlerAdapter implements HandlerAdapter,{
    private AnnotationHandlerAdapter target;

    @Override
    public boolean supports(Object handler) {
        return this.target.supports(handler);
    }

    @Override
    public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        request.setAttribute(HandlerMapping.INTROSPECT_TYPE_LEVEL_MAPPING, true);
        return this.target.handle(request, response, handler);
    }

    public void setTarget(AnnotationHandlerAdapter target){
        this.target = target;
    }

}

   <bean class="mypkg.DBAnnotationMethodHandlerAdapter">
        <property name="target">
            <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
        </property>
    </bean>
公共DBAnnotationMethodHandlerAdapter实现HandlerAdapter{
私有注释HandlerAdapter目标;
@凌驾
公共布尔支持(对象处理程序){
返回this.target.supports(处理程序);
}
@凌驾
公共ModelAndView句柄(HttpServletRequest请求、HttpServletResponse响应、对象处理程序)引发异常{
setAttribute(HandlerMapping.INTROSPECT\u TYPE\u LEVEL\u MAPPING,true);
返回this.target.handle(请求、响应、处理程序);
}
public void setTarget(AnnotationHandlerAdapter目标){
this.target=目标;
}
}

这应该可以解决当前的问题,但您可能会遇到其他问题,这显然是因为这里没有相反的答案,而且在spring框架中似乎没有更简单的方法来实现这一点

然而,我已经设法让它工作,并且我在github共享了一个项目,该项目可以使用maven构建,它添加了4个类,以简化动态添加类的过程。此项目可在上找到。我还将分享另一个项目来证明它是有效的

感谢Marten Deinum和Rossen Stoyanchev


对于那些对如何实现这一目标感兴趣的人,您需要做以下工作

  • 实现HandlerMapper的一个实例这将为您提供控制器类和要映射到的url之间的映射

    //   Copyright 2012 Wesley Acheson
    //
    //   Licensed under the Apache License, Version 2.0 (the "License");
    //   you may not use this file except in compliance with the License.
    //   You may obtain a copy of the License at
    //
    //       http://www.apache.org/licenses/LICENSE-2.0
    //
    //   Unless required by applicable law or agreed to in writing, software
    //   distributed under the License is distributed on an "AS IS" BASIS,
    //   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    //   See the License for the specific language governing permissions and
    //   limitations under the License.
    
    package com.wesley_acheson.spring;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import org.springframework.core.PriorityOrdered;
    import org.springframework.web.servlet.HandlerExecutionChain;
    import org.springframework.web.servlet.handler.AbstractUrlHandlerMapping;
    import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
    
    /**
     * A Handler mapper that delegates to a {@link UrlBackingBeanMapper} to know
     * whether it should match a url. If it does match a url then it adds the bean
     * which matches the url to the request.
     * 
     * @author Wesley Acheson
     * 
     */
    public class BackingBeanUrlHandlerMapper extends AbstractUrlHandlerMapping
            implements PriorityOrdered {
    
        private UrlBackingBeanMapper<?> urlMapper;
    
        /**
         * 
         * @param urlMapper
         *            The bean which matches urls with other beans.
         */
        public void setUrlMapper(UrlBackingBeanMapper<?> urlMapper) {
            this.urlMapper = urlMapper;
        }
    
        protected UrlBackingBeanMapper<?> getUrlMapper() {
            return urlMapper;
        }
    
        public static final String BACKING_BEAN_ATTRIBUTE = BackingBeanUrlHandlerMapper.class
                .getName() + ".backingBean";
    
        /**
         * The controller which control will be passed to if there is any beans
         * matching in @{link {@link #setUrlMapper(UrlBackingBeanMapper)}.
         */
        public Object controller;
    
        /**
         * @param controller
         *            <p>
         *            The controller which control will be passed to if there is any
         *            beans matching in @{link
         *            {@link #setUrlMapper(UrlBackingBeanMapper)}.
         */
        public void setController(Object controller) {
            this.controller = controller;
        }
    
        /*
         * (non-Javadoc)
         * 
         * @see org.springframework.web.servlet.handler.AbstractUrlHandlerMapping#
         * lookupHandler(java.lang.String, javax.servlet.http.HttpServletRequest)
         */
        @Override
        protected Object lookupHandler(String urlPath, HttpServletRequest request)
                throws Exception {
    
            if (urlMapper.isPathMapped(urlPath)) {
                Object bean = urlMapper.retrieveBackingBean(urlPath);
                return buildChain(bean, urlPath);
            }
    
            return super.lookupHandler(urlPath, request);
        }
    
        /**
         * Builds a handler execution chain that contains both a path exposing
         * handler and a backing bean exposing handler.
         * 
         * @param bean
         *            The object to be wrapped in the handler execution chain.
         * @param urlPath
         *            The path which matched. In this case the full path.
         * @return The handler execution chain that contains the backing bean.
         * 
         * @see {@link AbstractUrlHandlerMapping#buildPathExposingHandler(Object, String, String, java.util.Map)}
         *    
         */
        protected HandlerExecutionChain buildChain(Object bean, String urlPath) {
            // I don't know why but the super class declares object but actually
            // returns handlerExecution chain.
            HandlerExecutionChain chain = (HandlerExecutionChain) buildPathExposingHandler(
                    controller, urlPath, urlPath, null);
            addBackingBeanInteceptor(chain, bean);
            return chain;
        }
    
        /**
         * Adds an inteceptor which adds the backing bean into the request to an
         * existing HandlerExecutionChain.
         * 
         * @param chain
         *            The chain which the backing bean is being added to.
         * @param bean
         *            The object to pass through to the controller.
         */
        protected void addBackingBeanInteceptor(HandlerExecutionChain chain,
                Object bean) {
            chain.addInterceptor(new BackingBeanExposingInteceptor(bean));
    
        }
    
        /**
         * An Interceptor which adds a bean to a request for later consumption by a
         * controller.
         * 
         * @author Wesley Acheson
         * 
         */
        protected class BackingBeanExposingInteceptor extends
                HandlerInterceptorAdapter {
            private Object backingBean;
    
            /**
             * @param backingBean
             *            the bean which is passed through to the controller.
             */
            public BackingBeanExposingInteceptor(Object backingBean) {
                this.backingBean = backingBean;
            }
    
            @Override
            public boolean preHandle(HttpServletRequest request,
                    HttpServletResponse response, Object handler) throws Exception {
                request.setAttribute(BACKING_BEAN_ATTRIBUTE, backingBean);
                return true;
            }
        }
    
    }
    
  • 我还创建了一个BackingBean注释和一个接口来传递给我的处理程序addapers,因为我觉得它们更容易

  • 创建您的控制器。如果您使用我的代码,您将希望使用@BackingBean注释注入参数。控制器本身上的请求映射不能匹配任何好的URL(这是因为我们使用处理程序适配器绕过了这一步骤,并且我们不希望默认的注释处理程序拾取它)

  • 在spring中连接所有内容。下面是我的工作示例项目中的一个示例文件

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
        xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
    
        <!-- The controllers are autodetected POJOs labeled with the @Controller 
            annotation. -->
        <context:component-scan base-package="com.wesley_acheson"
            use-default-filters="false">
            <context:include-filter expression="org.springframework.stereotype.Controller"
                type="annotation" />
        </context:component-scan>
    
        <bean class="com.wesley_acheson.spring.BackingBeanUrlHandlerMapper"
            p:order="-1">
            <property name="controller">
                <!-- A simple example controller. -->
                <bean class="com.wesley_acheson.example.PageController" />
            </property>
            <!--  A simple example mapper. -->
            <property name="urlMapper">
                <bean class="com.wesley_acheson.example.PageBeanUrlMapper" />
            </property>
        </bean>
    
        <util:map id="pages">
            <entry key="/testPage1">
                <bean class="com.wesley_acheson.example.Page">
                    <property name="title" value="Test Page 1 title" />
                    <property name="contents"
                        value="This is the first test page.&lt;br /&gt; It's only purpose is to check
                        if &lt;b&gt;BackingBeans&lt;/b&gt; work." />
                </bean>
            </entry>
    
            <entry key="/test/nested">
                <bean class="com.wesley_acheson.example.Page">
                    <property name="title" value="Nested Path" />
                    <property name="contents"
                        value="This is another test page its purpose is to ensure nested pages work." />
                </bean>
            </entry>
        </util:map>
    
    
        <bean
            class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
            <property name="customArgumentResolver">
                <bean class="com.wesley_acheson.spring.BackingBeanArgumentResolver" />
            </property>
        </bean>
    
        <!-- Turns on support for mapping requests to Spring MVC @Controller methods 
            Also registers default Formatters and Validators for use across all @Controllers -->
        <mvc:annotation-driven />
    
    
        <!-- Handles HTTP GET requests for /resources/** by efficiently serving 
            up static resources -->
        <mvc:resources location="/, classpath:/META-INF/web-resources/"
            mapping="/resources/**" />
    
        <!-- Allows for mapping the DispatcherServlet to "/" by forwarding static 
            resource requests to the container's default Servlet -->
        <mvc:default-servlet-handler />
    
    </beans>
    
    
    

  • @fmucar到底是什么数据库驱动url模式?90%是在那里找到了正确的控制器,但不是控制器上的正确方法。如果你说的是将变量传递给控制器,我想最坏的情况是,我会将其作为请求属性注入,然后从那里获取控制器,但这感觉很笨拙。对不起,我必须这样做误解了你的问题。我将删除上面的评论。你能确认你的Spring版本吗MVC@BijuKunjummen我已将这些版本添加到票证中。版本3.1.0 Release我没有得到其他答案。您有赏金。使用此功能的示例可以在github上找到注意:此解决方案需要mvc 3.1+
    //   Copyright 2012 Wesley Acheson
    //
    //   Licensed under the Apache License, Version 2.0 (the "License");
    //   you may not use this file except in compliance with the License.
    //   You may obtain a copy of the License at
    //
    //       http://www.apache.org/licenses/LICENSE-2.0
    //
    //   Unless required by applicable law or agreed to in writing, software
    //   distributed under the License is distributed on an "AS IS" BASIS,
    //   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    //   See the License for the specific language governing permissions and
    //   limitations under the License.
    
    package com.wesley_acheson.spring;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import org.springframework.core.PriorityOrdered;
    import org.springframework.web.servlet.HandlerExecutionChain;
    import org.springframework.web.servlet.handler.AbstractUrlHandlerMapping;
    import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
    
    /**
     * A Handler mapper that delegates to a {@link UrlBackingBeanMapper} to know
     * whether it should match a url. If it does match a url then it adds the bean
     * which matches the url to the request.
     * 
     * @author Wesley Acheson
     * 
     */
    public class BackingBeanUrlHandlerMapper extends AbstractUrlHandlerMapping
            implements PriorityOrdered {
    
        private UrlBackingBeanMapper<?> urlMapper;
    
        /**
         * 
         * @param urlMapper
         *            The bean which matches urls with other beans.
         */
        public void setUrlMapper(UrlBackingBeanMapper<?> urlMapper) {
            this.urlMapper = urlMapper;
        }
    
        protected UrlBackingBeanMapper<?> getUrlMapper() {
            return urlMapper;
        }
    
        public static final String BACKING_BEAN_ATTRIBUTE = BackingBeanUrlHandlerMapper.class
                .getName() + ".backingBean";
    
        /**
         * The controller which control will be passed to if there is any beans
         * matching in @{link {@link #setUrlMapper(UrlBackingBeanMapper)}.
         */
        public Object controller;
    
        /**
         * @param controller
         *            <p>
         *            The controller which control will be passed to if there is any
         *            beans matching in @{link
         *            {@link #setUrlMapper(UrlBackingBeanMapper)}.
         */
        public void setController(Object controller) {
            this.controller = controller;
        }
    
        /*
         * (non-Javadoc)
         * 
         * @see org.springframework.web.servlet.handler.AbstractUrlHandlerMapping#
         * lookupHandler(java.lang.String, javax.servlet.http.HttpServletRequest)
         */
        @Override
        protected Object lookupHandler(String urlPath, HttpServletRequest request)
                throws Exception {
    
            if (urlMapper.isPathMapped(urlPath)) {
                Object bean = urlMapper.retrieveBackingBean(urlPath);
                return buildChain(bean, urlPath);
            }
    
            return super.lookupHandler(urlPath, request);
        }
    
        /**
         * Builds a handler execution chain that contains both a path exposing
         * handler and a backing bean exposing handler.
         * 
         * @param bean
         *            The object to be wrapped in the handler execution chain.
         * @param urlPath
         *            The path which matched. In this case the full path.
         * @return The handler execution chain that contains the backing bean.
         * 
         * @see {@link AbstractUrlHandlerMapping#buildPathExposingHandler(Object, String, String, java.util.Map)}
         *    
         */
        protected HandlerExecutionChain buildChain(Object bean, String urlPath) {
            // I don't know why but the super class declares object but actually
            // returns handlerExecution chain.
            HandlerExecutionChain chain = (HandlerExecutionChain) buildPathExposingHandler(
                    controller, urlPath, urlPath, null);
            addBackingBeanInteceptor(chain, bean);
            return chain;
        }
    
        /**
         * Adds an inteceptor which adds the backing bean into the request to an
         * existing HandlerExecutionChain.
         * 
         * @param chain
         *            The chain which the backing bean is being added to.
         * @param bean
         *            The object to pass through to the controller.
         */
        protected void addBackingBeanInteceptor(HandlerExecutionChain chain,
                Object bean) {
            chain.addInterceptor(new BackingBeanExposingInteceptor(bean));
    
        }
    
        /**
         * An Interceptor which adds a bean to a request for later consumption by a
         * controller.
         * 
         * @author Wesley Acheson
         * 
         */
        protected class BackingBeanExposingInteceptor extends
                HandlerInterceptorAdapter {
            private Object backingBean;
    
            /**
             * @param backingBean
             *            the bean which is passed through to the controller.
             */
            public BackingBeanExposingInteceptor(Object backingBean) {
                this.backingBean = backingBean;
            }
    
            @Override
            public boolean preHandle(HttpServletRequest request,
                    HttpServletResponse response, Object handler) throws Exception {
                request.setAttribute(BACKING_BEAN_ATTRIBUTE, backingBean);
                return true;
            }
        }
    
    }
    
    //   Copyright 2012 Wesley Acheson
    //
    //   Licensed under the Apache License, Version 2.0 (the "License");
    //   you may not use this file except in compliance with the License.
    //   You may obtain a copy of the License at
    //
    //       http://www.apache.org/licenses/LICENSE-2.0
    //
    //   Unless required by applicable law or agreed to in writing, software
    //   distributed under the License is distributed on an "AS IS" BASIS,
    //   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    //   See the License for the specific language governing permissions and
    //   limitations under the License.
    
    package com.wesley_acheson.spring;
    
    import javax.servlet.http.HttpServletRequest;
    
    import org.springframework.core.MethodParameter;
    import org.springframework.web.bind.support.WebDataBinderFactory;
    import org.springframework.web.context.request.NativeWebRequest;
    import org.springframework.web.method.support.HandlerMethodArgumentResolver;
    import org.springframework.web.method.support.ModelAndViewContainer;
    
    /**
     * Resolves method parameters which are annotated with {@link BackingBean}.
     * 
     * <b>Note:</b> Only works for Http requests.
     * 
     * @author Wesley Acheson
     * 
     */
    public class BackingBeanValueResolver implements HandlerMethodArgumentResolver {
    
        /**
         * Constructor.
         */
        public BackingBeanValueResolver() {
        }
    
        /**
         * Implementation of
         * {@link HandlerMethodArgumentResolver#supportsParameter(MethodParameter)}
         * that returns true if the method parameter is annotatated with
         * {@link BackingBean}.
         */
        @Override
        public boolean supportsParameter(MethodParameter parameter) {
            return parameter.hasParameterAnnotation(BackingBean.class);
        }
    
        @Override
        public Object resolveArgument(MethodParameter parameter,
                ModelAndViewContainer mavContainer, NativeWebRequest webRequest,
                WebDataBinderFactory binderFactory) throws Exception {
            return webRequest.getNativeRequest(HttpServletRequest.class)
                    .getAttribute(
                            BackingBeanUrlHandlerMapper.BACKING_BEAN_ATTRIBUTE);
        }
    
    }
    
    /**
     * 
     */
    package com.wesley_acheson.spring;
    
    import javax.servlet.http.HttpServletRequest;
    
    import org.springframework.core.MethodParameter;
    import org.springframework.web.bind.support.WebArgumentResolver;
    import org.springframework.web.context.request.NativeWebRequest;
    
    
    /**
     * @author Wesley Acheson
     *
     */
    public class BackingBeanArgumentResolver implements WebArgumentResolver {
    
        /* (non-Javadoc)
         * @see org.springframework.web.bind.support.WebArgumentResolver#resolveArgument(org.springframework.core.MethodParameter, org.springframework.web.context.request.NativeWebRequest)
         */
        @Override
        public Object resolveArgument(MethodParameter methodParameter,
                NativeWebRequest webRequest) throws Exception {
            if (methodParameter.hasParameterAnnotation(BackingBean.class))
            {
                HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
                Object parameter = request.getAttribute(BackingBeanUrlHandlerMapper.BACKING_BEAN_ATTRIBUTE);
                if (parameter == null)
                {
                    return UNRESOLVED;
                }
                if (methodParameter.getParameterType().isAssignableFrom(parameter.getClass()))
                {
                    return parameter;
                }
            }
    
    
            return UNRESOLVED;
        }
    
    }
    
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
        xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
    
        <!-- The controllers are autodetected POJOs labeled with the @Controller 
            annotation. -->
        <context:component-scan base-package="com.wesley_acheson"
            use-default-filters="false">
            <context:include-filter expression="org.springframework.stereotype.Controller"
                type="annotation" />
        </context:component-scan>
    
        <bean class="com.wesley_acheson.spring.BackingBeanUrlHandlerMapper"
            p:order="-1">
            <property name="controller">
                <!-- A simple example controller. -->
                <bean class="com.wesley_acheson.example.PageController" />
            </property>
            <!--  A simple example mapper. -->
            <property name="urlMapper">
                <bean class="com.wesley_acheson.example.PageBeanUrlMapper" />
            </property>
        </bean>
    
        <util:map id="pages">
            <entry key="/testPage1">
                <bean class="com.wesley_acheson.example.Page">
                    <property name="title" value="Test Page 1 title" />
                    <property name="contents"
                        value="This is the first test page.&lt;br /&gt; It's only purpose is to check
                        if &lt;b&gt;BackingBeans&lt;/b&gt; work." />
                </bean>
            </entry>
    
            <entry key="/test/nested">
                <bean class="com.wesley_acheson.example.Page">
                    <property name="title" value="Nested Path" />
                    <property name="contents"
                        value="This is another test page its purpose is to ensure nested pages work." />
                </bean>
            </entry>
        </util:map>
    
    
        <bean
            class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
            <property name="customArgumentResolver">
                <bean class="com.wesley_acheson.spring.BackingBeanArgumentResolver" />
            </property>
        </bean>
    
        <!-- Turns on support for mapping requests to Spring MVC @Controller methods 
            Also registers default Formatters and Validators for use across all @Controllers -->
        <mvc:annotation-driven />
    
    
        <!-- Handles HTTP GET requests for /resources/** by efficiently serving 
            up static resources -->
        <mvc:resources location="/, classpath:/META-INF/web-resources/"
            mapping="/resources/**" />
    
        <!-- Allows for mapping the DispatcherServlet to "/" by forwarding static 
            resource requests to the container's default Servlet -->
        <mvc:default-servlet-handler />
    
    </beans>