我以编程方式生成html页面。如何以编程方式将href设置为outter网站?
我有这个SRC
"https:/www.w.com/editor/?lon=-72.382769&lat=41.324657"
然而
一个href当我生成这样的HTML:
private Span getEditorSpan(CompleteRoutingResponseShort response) {
Span span4 = new Span();
for (int i = 0; i < response.alternatives.size(); i++) {
String editorUrl = editorUrlGenerator
.generateUrl(response.alternatives.get(i).response.results);
A a3 = new A();
a3.appendText("alt " + i);
a3.setTitle(response.alternatives.get(i).alternative_regression_id);
a3.setHref(editorUrl);
span4.appendChild(ImmutableList.of(a3, new Span().appendText("   ")));
}
return span4;
}
的结果实际上就是一个HREF到:
"http://localhost:63342/https:/www.w.com/editor/?lon=-72.382769&lat=41.324657"
这是结果html:
<span><a title="358_0" href="https:/www.w.com/editor/?lon=-71.18612999999999&lat=42.21286&zoom=4&segments=63385498,76487105,22543109,22503638,22527613,76599462,76599461,76599460">alt 0</a><span> </span></span>
如何使url直接在我的localhost域之外?
这是我的网址构建器:
UriBuilder builder = UriBuilder
.fromPath(Constants.EDITOR_BASE_URL)
.scheme("https");
builder.queryParam("lon", firstPath.x)
.queryParam("lat", firstPath.y)
.queryParam("zoom", 4)
.queryParam("segments", segmentsInUrl);
return builder.build().toString();
那是因为你只有一个在http: –
之后的单斜杠你的'https:/'是错的,它应该是'https://', ain为什么浏览器在相对url而不是完整的浏览器上回退,请检查您的数据源 –
如何提醒我的uri构建器? –