Spring 4.1.5,tiles 3.0.5 -----在ServletContext资源中定义名为'tilesConfigurer'的bean时出错

时间:2015-03-26 09:24:59

标签: google-app-engine spring-mvc tiles-3

的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>

Appengine错误日志

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 Server Error。试过以下建议,但仍然无效: 1. Why Tiles 3.0.5 does not work on Spring web 4.1.5
2. Tiles 3 with spring MVC 3 integration not working

提前致谢。

1 个答案:

答案 0 :(得分:1)

org.slf4j.LoggerFactory.reportMultipleBindingAmbiguity(..)

我会追逐那个。看起来你已经插入了多个日志记录实现......?