【发布时间】:2011-07-06 20:46:37
【问题描述】:
我真的找不到正确的方法来做到这一点。
我有这个方法并且它有效,但是做一些如此基本的事情似乎是一种变通方法。
FacesContext context = FacesContext.getCurrentInstance();
String baseURL = context.getExternalContext().getRequestContextPath();
String startDateString = sdf.format(startDate);
String endDateString = sdf.format(endDate);
String url = baseURL + "/Excel?pkgLineId="+selectedPkgLine.getPkgLineId()+"&dateStart=" + startDateString + "&dateEnd=" + endDateString;
try {
String encodeURL = context.getExternalContext().encodeResourceURL(url);
context.getExternalContext().redirect(encodeURL);
} catch (Exception e) {
} finally {
context.responseComplete();
}
我还了解到调用 servlet 不是最佳实践。如果我将我的 servlet 移动到 Web 服务会怎样?我该怎么称呼它?感谢您的帮助。
【问题讨论】: