English 中文(简体)
Wicket IndexedParam UrlCodingStrategy: how to specified Disappearance factors?
原标题:Wicket IndexedParamUrlCodingStrategy: how to specify missing parameters?

How can I specify empty positional params for IndexedParamUrlCodingStrategy?

我有<条码>。

    mount(new IndexedParamUrlCodingStrategy("search", SearchPage.class));

这使我能够建设诸如:

   /search/category/searchTerm/all/21-30

我可以成功地用以下方式检索位置部分:

    String category = parameters.getString("0", "");
    String searchTerm = parameters.getString("1", "");
    String filter = parameters.getString("2", "all");
    String pagination = parameters.getString("3", "1-10");

这使得卢爱尔人能够使用空洞的 para子,例如:

  /search//searchTerm/all/21-30   /* no category specified */

这项工程罚款,但我看上去:createlink to the SearchPage with loss params.

  params.put("0", ""); // try to set "empty" category
  params.put("1", "searchTerm");
  params.put("2", "all");
  params.put("3", "21-30");
  BookmarkablePageLink<SearchPage> link = new BookmarkablePageLink<SearchPage>("link", SearchPage.class, linkParams);

这导致与《欧洲公路货运公约》等联系:

  /search/searchTerm/all/21-30

而不是我的意图:

  /search//searchTerm/all/21-30
最佳回答

I don t know if this is possible with an IndexedParamUrlCodingStrategy. You might have to switch to an MixedParamUrlCodingStrategy that creates the URL by a defined set of parameters instead of "numeric parameters in ascending order starting with 0". This part of the Javadoc of the IndexedParamUrlCodingStrategy makes me think that either it s not suited for your usecase or you have to invent some magic non-empty-empty String (which just smells real bad). The IndexedParamUrlCodingStrategy wouldn t produce any "//" (just checked the sources)

89    if (!url.endsWith("/"))
90    {
91        url.append("/");
92    }

显然,你可以把它当作你的用地,或者说,作为一种 b子,但我不知道这是否只是一个特征。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签