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
\ 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
我认为这不重要,但我使用的是Struts 2版本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?
我正在使用Apache Tomcat。这就是我正在部署项目的地方。有没有办法在struts.xml中引用Tomcat的项目部署位置?
Something like:
<constant name="struts.multipart.saveDir" value="..\webapps\project\build\web" />
2 个解决方案
#1
0
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
你必须设置你的CATALINA_HOME
UPDATE
maybe this way, in your web.xml:
也许这样,在你的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
我还找到了一个链接,它适用于Log4j,但它是一样的。链接到解决方案
#2
0
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.
在运行时,您所拥有的只是运行已部署战争的服务器。应用程序的源代码以及它们在工作站上的目录与应用程序服务器无关。它不关心,也不必知道。应用程序服务器上可能有这样的目录,但它不确定,它是一个目录,就像机器上的所有其他目录一样。除了在某个配置文件中指定它之外别无他法。
#1
0
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
你必须设置你的CATALINA_HOME
UPDATE
maybe this way, in your web.xml:
也许这样,在你的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
我还找到了一个链接,它适用于Log4j,但它是一样的。链接到解决方案
#2
0
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.
在运行时,您所拥有的只是运行已部署战争的服务器。应用程序的源代码以及它们在工作站上的目录与应用程序服务器无关。它不关心,也不必知道。应用程序服务器上可能有这样的目录,但它不确定,它是一个目录,就像机器上的所有其他目录一样。除了在某个配置文件中指定它之外别无他法。