0
如何獲取當前項目的路徑:這是一個使用maven原型創建的動態web應用程序。我想使用不同的代碼,但我總是得到日食(C:\ Users \ Amira \ Desktop \ eclipse \ eclipse)的路徑 或路徑((C:\ software \ apache-tomcat-7.0.28 \ apache-tomcat-7.0.28 \ wtpwebapps \ TestProjectUI)如何獲取jsp頁面中eclipse項目的路徑
但我想在我的工作區中的項目路徑:C :\用戶\阿米拉\ junoWorkspace \ TestProjectUI
任何想法可以理解 謝謝
這裏是我的jsp:
<body>
<%
if (request.getParameter("btnSubmit") != null) //btnSubmit is the name of your button,not id of that button.
{
String className = request.getParameter("testclass");
System.out.println(className);
String[] command = {"CMD", "/C", "mvn -Dtest=" + className + " test"};
ProcessBuilder probuilder = new ProcessBuilder(command);
//You can set up your work directory
probuilder.directory(new File("C:\\Users\\Amira\\junoWorkspace\\TestProjectUI"));
Process process = probuilder.start();
//Read out dir output
java.io.InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
System.out.printf("Output of running %s is:\n", Arrays.toString(command));
while ((line = br.readLine()) != null) {
System.out.println(line);
}
//Wait to get exit value
try {
int exitValue = process.waitFor();
System.out.println("\n\nExit Value is " + exitValue);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
%>
<html:file properties="tonFichier" name="tonForm"/>
<p> Please specify a Test :<br>
<input type="file" name="testclass" size="40" >
</p>
<div>
<input type="submit" id="btnSubmit" name="btnSubmit" value="Execute Test"/>
</div>
</form>
</body>
路徑,爲什麼?這個問題的答案可能會有所幫助! – 2012-07-11 20:14:09
@PaulVargas我正在運行一個maven測試命令,所以我必須先訪問maven項目的路徑 – 2012-07-11 20:19:05