这样在servlet中使用:
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String filePath = config.getServletContext().getRealPath("/");
}
Run Code Online (Sandbox Code Playgroud)
怎么在游戏中获得RealPath?
玩耍就是为了轻松,对吗?所以让我们保持简单:
我使用
Play.applicationPath返回一个File.
请注意,Play类中还有一些其他很酷的路径: