Can I combine @controller and XML bean mapping in spring? -
i have @controller declared in spring , have bunch of mappings done so:
@requestmapping(value = "foo", method = requestmethod.get) public modelandview foo() { modelandview mav = new modelandview( "myjsp"); return mav; }
however every time want add simple jsp mapping need recompile , build new war , deploy.
this isnt bad except other members of team have requests , easier if can go test env , create mapping without having recompile.
i know can similar mapping using xml can @ same time have @controller defined?
like in example above how define mapping in xml rather in java?
or needed foo2 map myjsp2.jsp
i using spring mvc 3.2
look beannameurlhandlermapping
allows specify url patterns controllers in configuration. documentation
example
<beans> <bean id="handlermapping" class="org.springframework.web.servlet.handler.beannameurlhandlermapping"/> <bean name="/editaccount.form" class="org.springframework.web.servlet.mvc.simpleformcontroller"> <property name="formview" value="account"/> <property name="successview" value="account-created"/> <property name="commandname" value="account"/> <property name="commandclass" value="samples.account"/> </bean> <beans>
Comments
Post a Comment