I am converting an obsolete servlet application in Spring 3.1. As a result, some URLs are out of date. We had problems with our network, which will not be resolved in the near future. My boss does not want to believe that their forwarding will always work. So she asked me to make my own redirects to webapp.
Everything works fine, except that if the URL has a Spring 3.1 trailing slash, the controller class function that processes it will not be found.
http: //blah.blah.blah/acme/makedonation found, displayed and processed
http: //blah.blah.blah/acme/makedonation / not
Here is the controller class that I use to handle my legacy URLs
import org.springframework.stereotype.Controller; import org.springframework.validation.*; import org.springframework.ui.ModelMap; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.SessionAttributes; import org.apache.log4j.Logger; @Controller public class LegacyServletController { private static final Logger logger = Logger.getLogger(LegacyServletController.class);
I figured out and found this post stack overflow offering some suggestions, but I'm new to Spring and don't understand it enough to implement some of these suggestions. This, in particular, looks like it will fit my needs well:
spring 3.1. RequestMappingHandlerMapping allows you to set the useTrailingSlashMatch property. This is true by default. I think switching to a false solution to your problem,
Will someone give me a basic example of how to do this, point me to a URL that has such an example (I had no luck with Google) or point me to a better idea?
Thanks a lot Steve
Steve source share