Announcement Announcement Module
Collapse
No announcement yet.
Questions about REST-style URL's Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Questions about REST-style URL's

    Im having a couple problems trying to implement REST-style URL's

    My flowController is configured as follows:
    Code:
    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="alwaysUseFullPath" value="true" />
    		<property name="mappings">
    			<value>/**/**=flowController</value>
    		</property>
    	</bean>
    	
    	<bean id="flowController" class="org.springframework.webflow.executor.mvc.FlowController">
    		<property name="flowExecutor" ref="flowExecutor" />
    		<property name="argumentHandler">
    			<bean class="org.springframework.webflow.executor.support.RequestPathFlowExecutorArgumentHandler" />
    		</property>
    	</bean>
    now Im having 2 problems

    1. when my servlet mapping looks like this everything works fine
    Code:
    <servlet-mapping>
        <servlet-name>rsvp</servlet-name>
        <url-pattern>/rsvp/*</url-pattern>
      </servlet-mapping>
    but if I change it to look like this instead
    Code:
    <servlet-mapping>
        <servlet-name>rsvp</servlet-name>
        <url-pattern>/*</url-pattern>
      </servlet-mapping>
    
    and change
    
    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="alwaysUseFullPath" value="true" />
    		<property name="mappings">
    			<value>/**=flowController</value>
    		</property>
    	</bean>
    Then for some reason everytime I call a flow it somehow gets stuck in an infinite loop. If I call http://localhost/gradrsvp/login then my login flow get called over and over again until my browser times out. The reason I want to get it work this way is because currently my URL's look something like this
    http://localhost/gradrsvp/rsvp/login
    but as you can see from the mapping I want to cut out that /rsvp/ to shorten the URL so its not so long. does anyone know what the problem is with this?

    2. When i use the REST url's I cannot link any of my style sheets. in my jsp pages I have
    Code:
    <link rel="stylesheet" href="style.css" type="text/css">
    but my app throws an exception

    Code:
    org.springframework.webflow.execution.repository.BadlyFormattedFlowExecutionKeyException: Badly formatted flow execution key 'style.css', the expected format is '_c<conversationId>_k<continuationId>'
    This only happens when i have the REST url's mapped out....any ideas on this one?

    Thanks
    -Ray

  • #2
    REST style URLs?

    I'm confused - when I think of REST style URLs, I think of URLs which can be nicely bookmarked and possibly also give an indication towards a domain object/resource. I think you've got problems, but it's not so much with REST style URLs as just general configuration issues.

    If the only benefit you're getting by changing the servlet mapping is a 4 character difference (5 including the forward slash), I'd just leave as is.

    As far as REST style URLs, or at least bookmarkable URLs, I'd also like to see a bit of a best practice established on how to get this working with SWF. Creating a single controller/mapping to handle all my requests is nice, but in terms making it possible to bookmark pages, my current application is pretty lame.

    Suggestions would be more then welcome... and is another book coming on SWF? Expert Spring MVC and Web Flow left a lot of common concerns untouched. A book which concentrates on SWF would be much appreciated.

    Comment


    • #3
      meh...

      Heh, just after making the post above I Googled Spring Web Flow and REST URL's... suddenly I'm looking at the ItemList example with bookmarkable URLs and my faith in the Spring team is once again restored... I feel like some sort of biblical character who just doubted God.

      Well kinda...

      Comment


      • #4
        well its not a huge deal with extra 4-letters in there, but its something to where if I could get rid of it then it would be very nice. but since i havent found any way around it im just going to use .htaccess to do what I want. because basically Im just looking to help those who manually type in URL's, like I do alot. the less they have to type the better because honestly some the people that I make some of these apps for I need to make it as easy as possible on them otherwise its a disaster lol.

        but besides that does anyone have any ideas on my second problem about the errors when including the style sheet??

        Comment


        • #5
          style problem

          Yeah, the style sheet problem isn't too bad - all that is happening is now your style.css is being included in your servlet mapping, so when the browser page is loading, it's retreiving the style.css (GET /${app_name}/style.css) but that now matches your servlet mapping of "/${app_name}/*".

          Again, I'd just not worry about the few extra characters - you can put in an index.jsp in base of your application to redirect people to your main page:

          <%
          String contextPath = request.getContextPath();
          String redirectURL = contextPath + "/gui/main.html";
          response.sendRedirect(redirectURL);
          %>

          That should achieve your requirements pretty well; people hand typing your URL will not have to type in the servlet mapping and the rest of your application won't break.

          Comment

          Working...
          X