현재 프로젝트의 경로를 얻는 방법 : maven archetype으로 만든 동적 웹 애플리케이션입니다.JSP 페이지에서 이클립스 프로젝트의 경로를 얻는 방법
스크립틀릿 코드에서 JSP 페이지의 경로를 가져 오려면 다른 코드를 사용했지만 항상 이클립스 경로 (C : \ Users \ Amira \ Desktop \ eclipse \ eclipse)를 얻고 있습니다 또는 경로 (C : \ software \ apache-tomcat-7.0.28 \ apache-tomcat-7.0.28 \ wtpwebapps \ TestProjectUI)에서 웹 응용 프로그램의 웹 페이지를 열 수 있습니다. : \ 사용자 \ 어떤 생각이 을 이해할 수있을 것이다
아미라 \ 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>
경로는 무엇입니까? 이 질문에 대한 답이 도움이 될 수 있습니다! –
@PaulVargas 먼저 maven 테스트 명령을 실행하여 maven 프로젝트의 경로에 먼저 액세스해야합니다. –