问题
First time I am trying to integrate Tiles3 with spring MVC 3. My Spring servlet has the following entries:
<bean id="tilesviewResolver" class="org.springframework.web.servlet.view.tiles3.TilesViewResolver" p:order="0"/>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
The jar files I have in my project's class path are:
commons-beanutils-1.8.0.jar
commons-digester-2.0.jar
commons-lang-2.4.jar
commons-logging-1.0.4.jar
jstl-1.2.jar
log4j-1.2.16.jar
logback-access-1.0.0.jar
logback-classic-1.0.0.jar
logback-core-1.0.0.jar
logback-examples-1.0.0.jar
mysql-connector-java-5.0.5-bin.jar
org.springframework.asm-3.0.1.RELEASE-A.jar
org.springframework.beans-3.0.1.RELEASE-A.jar
org.springframework.context-3.0.1.RELEASE-A.
org.springframework.core-3.0.1.RELEASE-A.jar
org.springframework.expression-3.0.1.RELEASE
org.springframework.jdbc-3.0.1.RELEASE-A.jar
org.springframework.transaction-3.0.1.RELEAS
org.springframework.web-3.0.1.RELEASE-A.jar
slf4j-api-1.5.8.jar
slf4j-log4j12-1.5.10.jar
tiles-api-3.0.3.jar
tiles-autotag-core-runtime-1.1.0.jar
tiles-compat-3.0.3.jar
tiles-core-3.0.3.jar
tiles-el-3.0.3.jar
tiles-extras-3.0.3.jar
tiles-freemarker-3.0.3.jar
tiles-jsp-3.0.3.jar
tiles-mvel-3.0.3.jar
tiles-ognl-3.0.3.jar
tiles-request-api-1.0.3.jar
tiles-request-freemarker-1.0.3.jar
tiles-request-jsp-1.0.3.jar
tiles-request-mustache-1.0.3.jar
tiles-request-servlet-1.0.3.jar
tiles-request-servlet-wildcard-1.0.3.jar
tiles-request-velocity-1.0.3.jar
tiles-servlet-3.0.3.jar
tiles-template-3.0.3.jar
tiles-velocity-3.0.3.jar
But I am getting the error :
Cannot find class [org.springframework.web.servlet.view.tiles3.TilesConfigurer] for bean with name 'tilesConfigurer' defined in ServletContext resource [/WEB-INF/thinkTank-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.web.servlet.view.tiles3.TilesConfigurer
thinkTank-servlet.xml is my spring servlet, can anyone help, what I am doing wrong:
回答1:
add this snipt in your spring servlet
<beans:bean id="tilesViewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<beans:property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
</beans:bean>
<beans:bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<beans:property name="definitions">
<beans:list>
<beans:value>/WEB-INF/spring/appServlet/views.xml</beans:value>
</beans:list>
</beans:property>
</beans:bean>
回答2:
You need spring 3.2 for the org.springframework.web.servlet.view.tiles3 classes.
If for some reason you can't upgrade then you can download just the classes you need here from http://wever.org/spring-webmvc-tiles3-3.2.0.RC2-finn-1.jar That jar file should be compatible with the spring 3.0.1 you have, but i would still recommend upgrading to 3.2 if you can.
来源:https://stackoverflow.com/questions/20028295/tiles-3-with-spring-mvc-3-integration-not-working