spring mvc - HTTP request with RESTful URL and .htm URL -


url *.htm works fine. encounter problem when try access restful url without *.htm, server gives me 404 error. can solve problem replacing *.htm /. if break webpages. question how go supporting restful , regular http request through same spring controller? needs configured in web.xml? tried /rest/* not seems working either.

<servlet>     <servlet-name>dispatch</servlet-name>     <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>     <load-on-startup>1</load-on-startup> </servlet>  <servlet-mapping>     <servlet-name>dispatch</servlet-name>     <url-pattern>*.htm</url-pattern> </servlet-mapping> 

tried

<servlet-mapping>     <servlet-name>dispatch</servlet-name>     <url-pattern>/rest/*</url-pattern> </servlet-mapping> 

tested configuration 'type - i'

works when url set end .htm http://localhost:8080/controllername/my/123/url/value.htm

web.xml mapping

<servlet-mapping>     <servlet-name>dispatch</servlet-name>     <url-pattern>*.htm</url-pattern> </servlet-mapping>  <servlet-mapping>     <servlet-name>dispatch</servlet-name>     <url-pattern>/rest/*</url-pattern> </servlet-mapping> 

controller mapping

@requestmapping(value = "/my/{number}/url/{somevalue}", method = requestmethod.get, produces="application/xml") 

test configuration 'type - ii'

no other combination seems work when url not contain .htm

this may late, may issue defaultannotationhandlermapping in spring. will, default believe, automatically handle extentions, can turned off. also, servlet definition in web.xml should set accept urls ending in '*'.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -