我想通过使用下面给出的代码上传pdf文件.它提供浏览设施,但不上传文件.当我点击sendfile按钮时,显示uploadfile.html代码页.我怎样才能做到这一点???给定代码中的错误在哪里???
文件名,upload.html
<%@ page language="java" %>
<HTml>
<HEAD><TITLE>Display file upload form to the user</TITLE></HEAD>
<% // for uploading the file we used Encrypt type of multipart/
form-data and input of file type to browse and submit the file %>
<BODY> <FORM ENCTYPE="multipart/form-data" ACTION=
"uploadfile.html" METHOD=POST>
<br><br><br>
<center><table border="2" >
<tr><center><td colspan="2"><p align=
"center"><B>PROGRAM FOR UPLOADING THE FILE</B><center></td></tr>
<tr><td><b>Choose the file To Upload:</b>
</td>
<td><INPUT NAME="F1" TYPE="file"></td></tr>
<tr><td colspan="2">
<p align="right"><INPUT TYPE="submit" VALUE="Send File" ></p></td></tr>
<table>
</center>
</FORM>
</BODY>
</HTML>
Run Code Online (Sandbox Code Playgroud)
文件名 …
再会!
我在运行 JSP 程序时遇到以下错误。
java.lang.IllegalStateException: PWC3991: getOutputStream() has already been called for this response
Run Code Online (Sandbox Code Playgroud)
我的 JSP 中的 html 文件似乎不起作用。我的代码如下:
<%@page import = "java.util.*"%>
<%@page import = "javax.servlet.*"%>
<%@page import = "javax.servlet.http.*"%>
<%@page import= "session.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
Item item = (Item) request.getAttribute("invenItem");
if (item != null) {
out.println("<html><title>Inventory Item</title>");
out.println("<body><h1>Inventory Item Details:</h1>");
out.println("Stock ID : " + item.getStockID() + "<br/>"); …Run Code Online (Sandbox Code Playgroud) 这是我的JSP文件.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
//JFileChooser filechoose = new JFileChooser();
JFileChooser filechoose = new JFileChooser("D:\\");
filechoose.showOpenDialog(null);
File file = filechoose.getSelectedFile();
XLCauHoi.ImportXmlFileToData(file);
%>
<h4> ?ã xu?t file thành công </h4>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的问题是:JFileChooser当我在浏览器上运行时弹出2次.如果我在Java类中运行它,会JFileChooser弹出一次.我的问题是什么以及如何解决?