How to create a Spring 3 + Tiles 2 web application using REST-ful URLs?

I have damn temporary URLs with Spring 3.0 MVC. I just create HelloWorld to try how to create a RESTful webapp in Spring, nothing is theoretically complicated.

All the examples that I could find are based on configurations that pay attention to file extensions ("* .htm" or "* .do"), include the artificial directory name prefix ("/ foo") or even dot prefix paths ( ugly), all approaches that use some artificial regular expression pattern as a signal for a recognizer. For the REST approach, I want to avoid all these nasty things and use only the natural URL patterns of my application. I would suggest (possibly incorrectly) that in web.xml I set the url pattern to "/ *" and passed everything to the DispatcherServlet permission for permission, and then just relied on the URL patterns in my controller.

I cannot reliably get my resolver (s) to catch URL patterns, and in all my tests this results in a resource error not found, stack overflow (loop) or some kind of opaque Spring 3 ServletException stack trace is one of My current frustration with Spring is that error messages are often not very helpful.

I want to work with the Tiles 2 resolver. I placed my * .jsp files in WEB-INF / views / and had one index.jsp file in the application root directory, redirecting the index file set by my layout.xml (Tiles 2 Configurator).

I am doing all the standard Spring 3 configuration:

<mvc:annotation-driven />

<mvc:view-controller path="/" view-name="index"/>

<context:component-scan base-package="com.acme.web.controller" />

... UrlBasedViewResolver, InternalResourceViewResolver, UrlFilenameViewController .. Tiles 2. URL. , (), .

- , , , . , , , ( ) . HelloWorld, , .

, ( ), - -, - Spring 3 MVC + Tiles 2, URL- REST-ful (.., URL-, , ) Spring 3 / (.. Spring MVC)) ? ?

.

+5
3
<bean id="tilesviewResolver" class="org.springframework.web.servlet.view.tiles2.TilesViewResolver" 
            p:order="0"/>

<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles-defs/tilesConfig.xml</value>
            </list>
        </property>
</bean> 

. TilesViewResolver

+1

spring: petcare , . : https://src.springframework.org/svn/spring-samples/ : 1. bean ( xml)

<!-- Initializes the Apache Tiles CompositeView system -->
    <beans:bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <beans:property name="definitions">
            <beans:value>
                /WEB-INF/**/tiles.xml
            </beans:value>
        </beans:property>
        <beans:property name="checkRefresh" value="true" />
    </beans:bean>
  • , UrlBasedViewResolver

                          value = "org.springframework.web.servlet.view.tiles2.TilesView" /" >  

  • styles.xml / ..

0

All Articles