-->

如何获得Eclipse项目的jsp页面的路径(How to get the path of an e

2019-10-17 00:01发布

如何让我的当前项目的路径:它与Maven原型创建动态Web应用程序。

我想找回在scriptlet代码我的jsp页面的路径,我用不同的代码,但我一直都想与日食路径(C:\用户\阿米拉\桌面\日食\日食)或Web应用程序上的路径Tomcat的((C:\ SOFTWARE \ Apache的Tomcat的7.0.28 \ Apache的Tomcat的7.0.28 \ wtpwebapps \ TestProjectUI)

但我想在我的工作空间中的项目的路径: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>

Answer 1:

每当我有这样一个问题,我打印出所有的System.getProperties()看看是否有一个有我想要的信息。 这可能是你可以在这里做的最好的,因为Eclipse提供的唯一信息会通过属性。 如果没有信息提供的属性之一,你可以自己提供它作为你的启动配置的一部分,您可以使用workspace_loc在推出配置的东西变量。



文章来源: How to get the path of an eclipse project in jsp page