i new spring mvc. want implement this:
i have following urls, want them handled 1 controller:
/entity/*
in web.xml, defined dispatcher servlet this:
<servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/etc/webmvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/action/*</url-pattern> <url-pattern>/data/*</url-pattern> <url-pattern>/entity/*</url-pattern> </servlet-mapping>
and controller:
@controller @requestmapping(value="/entity") public class entitycontroller { @requestmapping(value="/*") public @responsebody object operate(@requestbody entityoperationrequest datareq){ return null; } }
this not work, how can make entitycontroller
handle urls begin /entity/
, following url hit it:
http://host:port/context_root/entity/sys/user http://host:port/context_root/entity/biz/order http://host:port/context_root/entity/biz/foo/bar ....
there different levels upto can perform url mapping (like class level, method level etc.) example you. spring mvc @requestmapping annotation example
Comments
Post a Comment