How to use Spring MVC to implement a front controller, but not using controllers

The title of this post may be confusing. I will try to clarify it best. I started a project using Spring MVC, it works great, no problem. After that, I realized that I went overboard a bit and found that I needed a front-end dispatcher, because all I needed was good URLs without extensions.

So instead of introducing a new font controller, I would like to take advantage of the existing Spring MVC installation. here is an example of a controller

 @RequestMapping("/accounts")
public String home() {

    return "accounts";
}

 @RequestMapping(value="/")
public String Home(){
    return "home";
}

as you can see, the returned string is what points to a view based on resourceviewresolver

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="prefix" value="/views/" />
  <property name="suffix" value=".jsp" />
</bean>

, . , .

? ?

.

+3
1

Spring 3 <mvc:view-controller> :

<mvc:view-controller path="/" view-name="home" />
<mvc:view-controller path="/accounts" view-name="accounts" />

. :

+4

All Articles