我在Java桌面环境中使用NanoHTTPD webserver 2.1.0.(没有Android)
一切正常......但不是使用POST方法上传文件(表格不支持PUT)
这是我的HTML代码:
<form method="post" enctype="multipart/form-data">
choose a file<br>
<input name="file" type="file" size="50" maxlength="100000"">
<button type="submit">upload</button>
</form>
Run Code Online (Sandbox Code Playgroud)
这是我的服务器方法:
public Response serve(IHTTPSession session) {
if (session.getMethod() == Method.POST) {
Map<String, String> files = new HashMap<String, String>();
session.parseBody(files);
//this prints {file=C:\path-to-java-tmp-files\NanoHTTPD-4635244586997909485}
//the number is always different
System.out.println(files.toString());
} else {
//page containing the index.html including the form
return page;
}
}
Run Code Online (Sandbox Code Playgroud)
这是问题:临时文件不存在.现有的另一个临时文件具有不同的"数字",这似乎是正确的文件,因为内容与上传文件的内容相同.那么如何获得正确的临时文件名呢?
另一个问题是:临时文件包含漏洞POST内容:
-----------------------------115801144322347
Content-Disposition: form-data; name="file"; filename="filename.txt"
Content-Type: application/octet-stream
-->content of the uploaded file
-----------------------------115801144322347--
Run Code Online (Sandbox Code Playgroud)
如果内容是pic或二进制文件,则这是一个问题.
似乎NanoHTTPD不会对POST请求做任何特殊操作.它总是一样...将请求保存到tmp文件并提供页面.所以: - 如何获得正确的临时文件? …
我有一个简单的 HTML 表格。每个 Cell 都有一个 input-tag。
是否可以使表格看起来像http://handsontable.com/?
我不能使用 handsontable,因为我的表做了一些特定于应用程序的事情。
有没有一种简单的方法,比如“是的,只需使用这个和这个 css 类”?
谢谢你的帮助;)
格鲁斯
编辑:好的,我将添加一些示例代码:
<table>
<tbody>
<tr>
<td>
<input/>
</td>
<td>
<input/>
</td>
<td>
<input/>
</td>
</tr>
<tr>
<td>
<input/>
</td>
<td>
<input/>
</td>
<td>
<input/>
</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
EDIT2:请不要混淆。关键是:我希望我的表格看起来像 Excel,而 handsontable 可以做到这一点。