问题
For example:
<constant name="struts.multipart.saveDir" value="temp" />
will save to:
\Apache Tomcat 7.0.14\bin\temp\upload__781d3178_13831f5e207__8000_00000003.tmp
So, instead, how do I make it go to:
C:\my_project\build\web\temp\
Without using the absolute file path because I don't want to reconfigure it each time the project moves. I just want the relative path basically.
EDIT 1:
I don't think it matters, but I'm using Struts 2 version 2.1.8.1
EDIT 2:
I'm using Apache Tomcat. That's where I'm deploying the project to. Is there no way to make a reference to Tomcat's project deployment location in the struts.xml?
Something like:
<constant name="struts.multipart.saveDir" value="..\webapps\project\build\web" />
回答1:
there are several ways to do this. here is the most easy way:
<constant name="struts.multipart.saveDir" value="${catalina.home}/webapps/project/web/temp"/>
you have to set your CATALINA_HOME
UPDATE
maybe this way, in your web.xml:
<context-param>
<param-name>catalina.home</param-name>
<param-value>path/to/your/tomcat</param-value>
</context-param>
UPDATE
I also found a link, it is for Log4j, but it is the same. Link-To-Solution
回答2:
The project is where the sources of the application, on the developer workstation, are.
At runtime, all you got is a server running a deployed war. The sources of the application, and the directory where they are on your workstation are irrelevant for the app server. It doesn't care, and doesn't have to know. There might be such a directory on the app server machine, but it's not sure, and it's a directory as all the other directories on the machine. There is no other way than specifying it in some config file.
来源:https://stackoverflow.com/questions/11239923/how-do-you-get-the-project-path-in-struts-2