如何避免Wicket中的资源路径冲突?

时间:2015-10-02 13:58:51

标签: wicket url-mapping

我无法让资源路径在Wicket中正常运行。我所做的是我有两个资源。

  • ProfileResource:/profiles
  • ProfileHistoryResource:/profiles/{username}/history

我将两个资源安装到这些路径的方式如下所示。

   mountResource("/profiles", new ResourceReference("profilesResource") {
        ProfilesResource resource = new ProfilesResource();

        @Override
        public IResource getResource() {
            return resource;
        }

    });

    mountResource("/profiles/{username}/history", new ResourceReference("profilesHistoryResource") {
        ProfilesHistoryResource resource = new ProfilesHistoryResource();

        @Override
        public IResource getResource() {
            return resource;
        }

    });

然而,这不起作用。一旦我引入了/profiles/{username}/history资源,就会停止工作,当我尝试加载/profiles/testuser/history时出现以下错误:

  

找不到合适的方法。网址'个人资料/ testuser / rentalaccesses'和HTTP   方法GET

我在这里做错了什么?为什么这些映射不起作用?

ProfilesResource

public class ProfilesResource extends GenericRestResource {

    @MethodMapping(value = "/{username}", httpMethod = HttpMethod.GET)
    public String get(String username) {
        return "success";
    }

ProfilesHistoryResource

public class ProfilesHistoryResource extends GenericRestResource {

    @MethodMapping(value = "/", httpMethod = HttpMethod.GET)
    public String get(String username) {
        return "success";
    }

}

1 个答案:

答案 0 :(得分:1)

Apache Wicket(核心)不支持{placeholder}。它支持${mandatory}#{optional}。你绝对不能将{..}与WebApplication#mountResource()`。

一起使用

WicketStuff RestAnnotations支持@MethodMapping和co。