Struts2 中读取静态资源文件

If it is placed in the webapp's classpath, then just use:

If it is placed in the global classpath, then use:

If it is placed in the webcontent, then just use:

The examples assumes that they're placed in the root. You can of course use relative path as opposed to the classpath root or webcontent root, e.g. path/to/file.txt. You can get the ServletContextin Struts by ServletActionContext#getServletContext().

发布者