0

I currently have a @Controller declared in spring and have a bunch of mappings done like so:

@RequestMapping(value = "foo", method = RequestMethod.GET)
public ModelAndView foo() {
    ModelAndView mav = new ModelAndView(
            "myjsp");
    return mav;
}

However every time I want to add a simple JSP mapping I need to recompile and build a new war and deploy.

This isnt so bad except sometimes other members of the team have requests and it would be easier if they can just go into the test env and create the mapping themselves without having to recompile.

I know that you can do similar mapping using xml but can I do this at the same time that I have the @Controller defined?

Like in the example above how could I define that mapping in XML rather than in java?

or say I needed foo2 to map to myjsp2.jsp

I am using spring MVC 3.2

4

1 回答 1

0

查看BeanNameUrlHandlerMapping哪些允许您在配置中为控制器指定 url 模式。 文档

例子

<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>
于 2013-04-05T14:19:27.173 回答