Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用HtmlUnit以表单形式提交文件_Java_Htmlunit - Fatal编程技术网

Java 如何使用HtmlUnit以表单形式提交文件

Java 如何使用HtmlUnit以表单形式提交文件,java,htmlunit,Java,Htmlunit,我对这张表格有问题 <form action="/incoming/Upload.cfg" enctype="multipart/form-data" method="post" onsubmit="return doSubmit();"> <table id="autoWidth" border="0" style="width: 100%;"> <tbody> <tr> <td class="h1"

我对这张表格有问题

<form action="/incoming/Upload.cfg" enctype="multipart/form-data" method="post" onsubmit="return doSubmit();">
  <table id="autoWidth" border="0" style="width: 100%;">
    <tbody>
      <tr>
        <td class="h1" colspan="4" id="t_title">
          Резервная копия и Восстановление
        </td>
      </tr>
      <tr>
        <td class="blue" colspan="4"/>
      </tr>
      <tr>
        <td class="Item" id="t_backup">
          Сохранить:
        </td>
        <td colspan="3">
          <input type="button" class="buttonBigL" name="Backup" value="Резервная копия" onclick="location.href='config.bin';"/>
        </td>
      </tr>
      <tr>
        <td class="Item" id="t_file">
          Файл:
        </td>
        <td>
          <input class="text" name="filename" type="file" size="20" onkeydown="return false"/>

            
        </td>
        <td>
          <input name="Restore" type="submit" class="buttonBigL" id="Submit" value="Восстановить"/>
        </td>
        <td width="100%">
           
        </td>
      </tr>
      <tr>
        <td class="blue" colspan="4"/>
      </tr>
    </tbody>
  </table>
</form>

什么也没发生

代码在工作,过载消失了。但是我在spring容器中运行了测试,出于某种原因,我得到了这个错误

@RunWith(SpringRunner.class)
@SpringBootTest
如果你没有弹簧就跑,一切正常

htmlForm.<HtmlFileInput>getInputByName("filename").setValueAttribute(model);
htmlForm.<HtmlFileInput>getInputByName("filename").setContentType("multipart/form-data");
HtmlPage restore = htmlForm.getInputByName("Restore").click(); 
决定

@RunWith(SpringRunner.class)
@SpringBootTest
htmlForm.<HtmlFileInput>getInputByName("filename").setValueAttribute(model);
htmlForm.<HtmlFileInput>getInputByName("filename").setContentType("multipart/form-data");
HtmlPage restore = htmlForm.getInputByName("Restore").click(); 
        webClient.getOptions().setTimeout(20000);
        webClient.getOptions().setThrowExceptionOnScriptError(false);
        webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
        webClient.getOptions().setCssEnabled(false);
        webClient.getOptions().setJavaScriptEnabled(true);
        webClient.getOptions().setUseInsecureSSL(true);
        webClient.getOptions().setRedirectEnabled(true);