Java Spring是否提供类似于Symfony2路由系统的任何路由系统?

时间:2014-07-09 13:04:29

标签: spring symfony

我是Spring的新人,但对Symfony2有一些经验。我喜欢Symfony的路由系统。 Spring MVC是否提供类似的东西?

1 个答案:

答案 0 :(得分:0)

是的,但是这一切都是通过函数上面的注释完成的,而不是将其放入文件然后引用该文件。它看起来像这样

@RequestMapping({"/configuration/{configurationId}/banners"})
public String Foo(@PathVariable long configurationId) {
        //do something here 
        return "the return";
    }

您还可以使用安全性做很多事情,您可以在其中覆盖特定目录的权限。喜欢这个

<security:intercept-url pattern="/" access="hasAnyRole('ROLE_ANONYMOUS','ROLE_SUPER','ROLE_OWNER','ROLE_EMPLOYEE')" />
    <security:intercept-url pattern="/page1" access="hasAnyRole('ROLE_ANONYMOUS','ROLE_SUPER','ROLE_OWNER','ROLE_EMPLOYEE')" />
    <security:intercept-url pattern="/page2" access="hasAnyRole('ROLE_ANONYMOUS','ROLE_SUPER','ROLE_OWNER','ROLE_EMPLOYEE')" />
    <security:intercept-url pattern="/page3/page4" access="hasAnyRole('ROLE_ANONYMOUS','ROLE_SUPER','ROLE_OWNER','ROLE_EMPLOYEE')" />
    <security:intercept-url pattern="/page5" access="hasAnyRole('ROLE_ANONYMOUS','ROLE_SUPER','ROLE_OWNER','ROLE_EMPLOYEE')" />
    <security:intercept-url pattern="/login/*" access="hasAnyRole('ROLE_ANONYMOUS','ROLE_SUPER','ROLE_OWNER','ROLE_EMPLOYEE')" />
    <security:intercept-url pattern="/**" access="hasAnyRole('ROLE_SUPER','ROLE_OWNER','ROLE_EMPLOYEE')" />