java:
getServletContext().getRealPath("/")
struts2:
ResourceBundle resource = ResourceBundle.getBundle("voicefileInfo");
ActionContext ac = ActionContext.getContext();
ServletContext sc = (ServletContext) ac.get(ServletActionContext.SERVLET_CONTEXT);
String LogDir = sc.getRealPath("/").concat(resource.getString("LogDir"));
都可利用severlet中的getRealPath("/")方法
本文介绍了如何使用Java和Struts2框架中的getRealPath方法来获取应用的根目录路径。通过Servlet API中的getRealPath方法,可以实现路径的动态获取,这对于文件操作尤其重要。
252

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



