Announcement Announcement Module
Collapse
No announcement yet.
Spring 3 MVC RESTful "/{xxxx}" clashing with DWR "/engine.js" Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 3 MVC RESTful "/{xxxx}" clashing with DWR "/engine.js"

    I have an Annotated controller mapped like

    Code:
    @Controller
    public class UsernameController {
    	
    	
    	@Autowired
    	private UsernameService usernameService;
    
    
    	@RequestMapping(value = "/{username}",method = RequestMethod.GET)
    	public String getAccount(Model model, 
    		@PathVariable("username") String username, 
    .
    .
    .

    I want the username to be accessed like so: www.myapp.com/username
    This works perfectly along with other mappings E.g. value = "/login" or value = "/register"

    Compile Log
    Code:
    Mapped URL path [/{userName}] onto handler [com.myapp.web.UsernameController@1921eac]

    I introduce DWR (Direct Web Remoting) into Spring and it looks like it should work.

    Compile Log
    Code:
    Mapped URL path [/engine.js] onto handler [org.directwebremoting.spring.DwrController@1104764]

    Now the problem is when I load a jsp page that contains the link to the engine.js file.

    Code:
    <head> 
    .
    .
    <script type='text/javascript' src='/myapp/dwr/engine.js'></script>
    .
    </head>
    Spring skips the DwrController and tries the DispatcherServlet.

    This is thinks that /engine.js is the /{userName} of my UsernameController.
    Enters this in the console log

    Code:
    DEBUG DispatcherServlet:834 - DispatcherServlet with name 'springmvc' determining Last-Modified value for [/myapp/dwr/engine.js]
    DEBUG DefaultAnnotationHandlerMapping:178 - Mapping [/engine.js] to handler 'com.myapp.web.UsernameController@1921eac'
    DEBUG DispatcherServlet:850 - Last-Modified value for [/events/dwr/engine.js] is: -1
    DEBUG DispatcherServlet:683 - DispatcherServlet with name 'springmvc' processing GET request for [/myapp/dwr/engine.js]
    So is there anyway to get /engine.js be mapped to /dwr/files/engine.js or change its mapping to keep
    usernames at the end of url "www.example.com/username"?
Working...
X