Spring 4.1.5,磁贴 3.0.5 ----- 创建在 ServletContext 资源中定义了名称"tilesConfigurer"的 Bean 时出错



web.xml

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
        <listener>
       <listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class>
   </listener>

dispatcherServlet xml

    <mvc:annotation-driven/>  
        <context:annotation-config/>
<mvc:view-controller path="/"/>
        <mvc:view-controller path="/contact.do"/>
        <mvc:view-controller path="/hello.do"/>
      <bean id="viewResolver" class="org.springframework.web.servlet.view.tiles3.TilesViewResolver"/>
        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="/jsp/" />
            <property name="suffix" value=".jsp" />
            <property name="order" value="0" />
        </bean>
        <bean id="tilesConfigurer"  
            class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">  
            <property name="definitions">  
                <list>  
                    <value>/WEB-INF/tiles.xml</value>  
                </list>  
            </property>  
        </bean>  

控制器类。

 @RequestMapping(value = "/", method = RequestMethod.GET)  
        public String first(ModelMap model) {  
            System.out.println("Inside first method");
            return "index";  
        }  
     @RequestMapping(value = "/addContact.do", method = RequestMethod.POST)  
        public String addContact(ModelMap model) {  
            System.out.println("Inside addContact method");
            return "redirect:/contact.do";  
        }  
        @RequestMapping(value="/contact.do",method = RequestMethod.GET)  
        public String showContacts(ModelMap model) {  
            System.out.println("Inside showContacts method");
            return "contact"; 
        }  
        @RequestMapping("/hello.do")  
        public ModelAndView helloWorld(ModelMap model) {  
            String message = "Hello World, Spring MVC @ Javatpoint";  
            return new ModelAndView("hello", "message", message);  
        }  

tiles.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC  
       "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"  
       "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">  
<tiles-definitions>  
    <definition name="base.definition"  template="/jsp/layout.jsp">  
        <put-attribute name="title" value="" />  
        <put-attribute name="header" value="/jsp/header.jsp" />  
        <put-attribute name="menu" value="/jsp/menu.jsp" />  
        <put-attribute name="body" value="" />  
        <put-attribute name="footer" value="/jsp/footer.jsp" />  
    </definition>  
    <definition name="contact" extends="base.definition">  
        <put-attribute name="title" value="Contact Manager" />  
        <put-attribute name="body" value="/jsp/contact.jsp" />  
    </definition>  
    <definition name="hello" extends="base.definition">  
        <put-attribute name="title" value="Hello Spring MVC" />  
        <put-attribute name="body" value="/jsp/hello.jsp" />  
    </definition>  
</tiles-definitions>

附件错误日志

Uncaught exception from servlet
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tilesConfigurer' defined in ServletContext resource [/WEB-INF/SpringMVCtiles-servlet.xml]: Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError

Caused by: java.lang.ExceptionInInitializerError
    at org.slf4j.LoggerFactory.reportMultipleBindingAmbiguity(LoggerFactory.java:260)
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:140)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:121)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:332)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:284)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:305)
    at org.apache.tiles.impl.BasicTilesContainer.<init>(BasicTilesContainer.java:71)
    at org.apache.tiles.factory.BasicTilesContainerFactory.instantiateContainer(BasicTilesContainerFactory.java:107)

当从浏览器执行时,上述异常会产生500服务器错误。尝试了以下建议,但仍然无效:1.为什么Tiles 3.0.5在Spring web 4.1.5上不起作用
2.具有spring MVC 3集成的Tiles 3不工作

提前谢谢。

org.slf4j.LoggerFactory.reportMultipleBindingAmbiguity(..)

我会追查的。看起来您已经插入了多个日志记录实现…?

最新更新