使用UriComponentsBuilder在Java中使用#连接uri

时间:2016-05-11 06:31:00

标签: java url path

以下是我的代码库:

@Component({
    selector: 'my-list',
    template: `
        <ul  [items]="items">
            <li *ngFor="let item of items" dcl-wrapper [type]="renderer" ></li>
        </ul>
    `
})
export class MyList {
    @Input() renderer: ListItemRenderer;
    @Input() items: any[];
    ...
}

String url = "http://sample.domain.com"; // it may ends with '#param=value UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(url); Map<String, String> uriVariables = new LinkedHashMap<String, String>(); StringBuilder params = new StringBuilder(); // fill uriVariables and params 的最终值为params

param1={param1}&param2={param2}用于替换uriVariables中的{param1}{param2}

我的问题是,如何使用params生成网址?

builderurl#params

e.g。

我尝试了url#param=value&params,但结果是

http://sample.domain.com/%23/param1=value1&param2=value2

1 个答案:

答案 0 :(得分:0)

尝试使用UriComponentsBuilder.fragment()

e.g。 builder.fragment("param=value")