Tapestry里怎么实现Jsp里的ServletContext.getRealPath("/")的功能。
getRequestCycle().getInfrastructure().getContextPath();
@InjectObject("service:tapestry.globals.WebContext")
public abstract WebContext getWebContext();
getWebContext().getRealPath("/upload/")
@InjectObject("infrastructure:contextPath")
public abstract String getContextPath();
Then write some computeUrl method similar to this one (just typed this in,
no guarantee that this will work).
public String computeUrl() {
String locale = getLocale().getCountry().toLowerCase();
return getContextPath() + "/Public/flags/" + locale + ".gif";
}
Tapestry中获取真实路径
本文介绍在Tapestry框架中如何实现类似JSP中ServletContext.getRealPath(/)的功能,通过使用WebContext接口的getRealPath方法来获取文件的真实路径。

被折叠的 条评论
为什么被折叠?



