听说我很难让 mvc 3 和瓷砖一起工作
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.view.tiles2.TilesConfigurer;
import org.springframework.web.servlet.view.tiles2.TilesViewResolver;
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {"foo"})
public class WebMvcConfig extends WebMvcConfigurationSupport {
@Override
public void configureDefaultServletHandling(final DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}
和 ...
@Configuration
public class ViewConfiguration {
@Bean
public TilesConfigurer tilesConfigurer() {
return new TilesConfigurer();
}
@Bean
public TilesViewResolver tilesViewResolver() {
TilesViewResolver tilesViewResolver = new TilesViewResolver();
tilesViewResolver.setOrder(2);
return tilesViewResolver;
}
和下面的瓷砖配置
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="mainLayout" template="/view/layout/layout.jsp">
<put-attribute name="header" value="/view/layout/header.jsp"/>
<put-attribute name="menu" value="/view/layout/menu.jsp"/>
<put-attribute name="footer" value="/view/layout/footer.jsp"/>
<put-attribute name="body" value="/view//layout/body.jsp"/>
</definition>
<definition name="test" extends="mainLayout">
<put-attribute name="body" value="/view/test.jsp"/>
</definition>
</tiles-definitions>
这是我的测试控制器
@Controller
public class TestController {
@RequestMapping("/hello")
public String helloWorld() {
return "test";
}
}
这是输出
DispatcherServlet.initContextHolders(986) | Bound request context to thread: org.apache.catalina.connector.RequestFacade@1b4c72c8
DispatcherServlet.doService(823) | DispatcherServlet with name 'dispatcher' processing GET request for [/trd/hello]
DispatcherServlet.getHandler(1088) | Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping@eca5a40] in DispatcherServlet with name 'dispatcher'
RequestMappingHandlerMapping.getHandlerInternal(219) | Looking up handler method for path /hello
RequestMappingHandlerMapping.lookupHandlerMethod(263) | Found 1 matching mapping(s) for [/hello] : [{[/hello],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}]
RequestMappingHandlerMapping.getHandlerInternal(226) | Returning handler method [public java.lang.String ir.parsdeveloper.web.controller.TestController.helloWorld()]
DefaultListableBeanFactory.doGetBean(246) | Returning cached instance of singleton bean 'testController'
DispatcherServlet.getHandlerAdapter(1122) | Testing handler adapter [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter@6eb2756]
DispatcherServlet.doDispatch(912) | Last-Modified value for [/trd/hello] is: -1
HandlerMethod.invokeForRequest(129) | Invoking [helloWorld] method with arguments []
HandlerMethod.invokeForRequest(135) | Method [helloWorld] returned [test]
HandlerMethodReturnValueHandlerComposite.getReturnValueHandler(78) | Testing if return value handler [org.springframework.web.servlet.mvc.method.annotation.ModelAndViewMethodReturnValueHandler@2903ccd9] supports [class java.lang.String]
HandlerMethodReturnValueHandlerComposite.getReturnValueHandler(78) | Testing if return value handler [org.springframework.web.method.annotation.ModelMethodProcessor@387dcf98] supports [class java.lang.String]
HandlerMethodReturnValueHandlerComposite.getReturnValueHandler(78) | Testing if return value handler [org.springframework.web.servlet.mvc.method.annotation.ViewMethodReturnValueHandler@4bc82121] supports [class java.lang.String]
HandlerMethodReturnValueHandlerComposite.getReturnValueHandler(78) | Testing if return value handler [org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor@3ff72465] supports [class java.lang.String]
HandlerMethodReturnValueHandlerComposite.getReturnValueHandler(78) | Testing if return value handler [org.springframework.web.servlet.mvc.method.annotation.CallableMethodReturnValueHandler@5979da9f] supports [class java.lang.String]
HandlerMethodReturnValueHandlerComposite.getReturnValueHandler(78) | Testing if return value handler [org.springframework.web.servlet.mvc.method.annotation.DeferredResultMethodReturnValueHandler@4f002a9d] supports [class java.lang.String]
HandlerMethodReturnValueHandlerComposite.getReturnValueHandler(78) | Testing if return value handler [org.springframework.web.servlet.mvc.method.annotation.AsyncTaskMethodReturnValueHandler@6271edc8] supports [class java.lang.String]
HandlerMethodReturnValueHandlerComposite.getReturnValueHandler(78) | Testing if return value handler [org.springframework.web.method.annotation.ModelAttributeMethodProcessor@4f432acf] supports [class java.lang.String]
HandlerMethodReturnValueHandlerComposite.getReturnValueHandler(78) | Testing if return value handler [org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor@468f7aa2] supports [class java.lang.String]
HandlerMethodReturnValueHandlerComposite.getReturnValueHandler(78) | Testing if return value handler [org.springframework.web.servlet.mvc.method.annotation.ViewNameMethodReturnValueHandler@5522a7b5] supports [class java.lang.String]
DispatcherServlet.render(1206) | Rendering view [org.springframework.web.servlet.view.tiles2.TilesView: name 'test'; URL [test]] in DispatcherServlet with name 'dispatcher'
TilesView.render(257) | Rendering view with name 'test' with model {} and static attributes {}
DefaultListableBeanFactory.getBeanDefinition(566) | No bean named 'requestDataValueProcessor' found in org.springframework.beans.factory.support.DefaultListableBeanFactory@5f1c34fb: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,webMvcConfig,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,viewConfiguration,testController,tilesConfigurer,tilesViewResolver,org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration,requestMappingHandlerMapping,mvcContentNegotiationManager,viewControllerHandlerMapping,beanNameHandlerMapping,resourceHandlerMapping,defaultServletHandlerMapping,requestMappingHandlerAdapter,mvcConversionService,mvcValidator,httpRequestHandlerAdapter,simpleControllerHandlerAdapter,handlerExceptionResolver]; root of factory hierarchy
BasicTilesContainer.render(615) | Render request recieved for definition 'test'
DispatcherServlet.initContextHolders(986) | Bound request context to thread: org.apache.catalina.core.ApplicationHttpRequest@a750bb9
DispatcherServlet.doService(823) | DispatcherServlet with name 'dispatcher' processing GET request for [/trd/view/thirdParty/layout/layout.jsp]
DispatcherServlet.getHandler(1088) | Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping@eca5a40] in DispatcherServlet with name 'dispatcher'
RequestMappingHandlerMapping.getHandlerInternal(219) | Looking up handler method for path /view/thirdParty/layout/layout.jsp
RequestMappingHandlerMapping.getHandlerInternal(229) | Did not find handler method for [/view/thirdParty/layout/layout.jsp]
DispatcherServlet.getHandler(1088) | Testing handler map [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping@696911f6] in DispatcherServlet with name 'dispatcher'
BeanNameUrlHandlerMapping.getHandlerInternal(127) | No handler mapping found for [/view/thirdParty/layout/layout.jsp]
DispatcherServlet.getHandler(1088) | Testing handler map [org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport$EmptyHandlerMapping@10f98160] in DispatcherServlet with name 'dispatcher'
DispatcherServlet.getHandler(1088) | Testing handler map [org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport$EmptyHandlerMapping@6c9cce54] in DispatcherServlet with name 'dispatcher'
DispatcherServlet.getHandler(1088) | Testing handler map [org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport$EmptyHandlerMapping@2aae2481] in DispatcherServlet with name 'dispatcher'
ageNotFound.noHandlerFound(1108) | No mapping found for HTTP request with URI [/trd/view/thirdParty/layout/layout.jsp] in DispatcherServlet with name 'dispatcher'
DispatcherServlet.resetContextHolders(996) | Cleared thread-bound request context: org.apache.catalina.core.ApplicationHttpRequest@a750bb9
DispatcherServlet.processRequest(951) | Successfully completed request
AnnotationConfigWebApplicationContext.publishEvent(332) | Publishing event in WebApplicationContext for namespace 'dispatcher-servlet': ServletRequestHandledEvent: url=[/trd/view/thirdParty/layout/layout.jsp]; client=[127.0.0.1]; method=[GET]; servlet=[dispatcher]; session=[null]; user=[null]; time=[804ms]; status=[OK]
DispatcherServlet.resetContextHolders(996) | Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@1b4c72c8
DispatcherServlet.processRequest(951) | Successfully completed request
AnnotationConfigWebApplicationContext.publishEvent(332) | Publishing event in WebApplicationContext for namespace 'dispatcher-servlet': ServletRequestHandledEvent: url=[/trd/hello]; client=[127.0.0.1]; method=[GET]; servlet=[dispatcher]; session=[null]; user=[null]; time=[7716ms]; status=[OK]
我知道控制器正在工作并返回“测试”作为输出但是当弹簧去寻找视图时有一些问题。我认为 /trd/view/layout/layout.jsp 会找到但无法检测到资源的位置。我不知道更多。请帮忙