1
我
正在写包含一个按钮,一个jsp页面,我把代码中的scriptlet执行是刷新JSP页面
每一件事情是运行好后,但经过反复的时候我刷新页面代码再次执行而不点击按钮。所以我想摆脱这一点。
这里是我的JSP代码:
<%
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>
任何想法可以理解 谢谢
但我不使用servlet – 2012-07-12 07:58:49
我没有得到你。你可以在你的jsp中发布“
谢谢heree的表单标签