在struts2中上传文件

在struts2中上传文件,struts2,Struts2,我需要文件上传到struts2并存储到服务器的位置,我用谷歌没有用,谁能给更好的主意。提前感谢谷歌,它可能有助于检查您键入的内容:是“struts2”,不是“struts” 无论如何,你不需要谷歌,官方文件就足够了 以下是struts2文件上传的完整代码 操作文件(fileupload.java) index.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="IS

我需要文件上传到struts2并存储到服务器的位置,我用谷歌没有用,谁能给更好的主意。提前感谢谷歌,它可能有助于检查您键入的内容:是“struts2”,不是“struts”

无论如何,你不需要谷歌,官方文件就足够了


以下是struts2文件上传的完整代码

操作文件(fileupload.java)

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>File Upload</title>
</head>
<body>
   <form action="upload" method="post" enctype="multipart/form-data">
      <label for="myFile">Upload your file</label>
      <input type="file" name="myFile" />
      <input type="submit" value="Upload"/>
   </form>
</body>
</html>

文件上传
上传你的文件
success.jsp

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>File Upload Success</title>
</head>
<body>
You have successfully uploaded <s:property value="myFileFileName"/>
</body>
</html>

文件上传成功
您已成功上载
干杯

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>File Upload Success</title>
</head>
<body>
You have successfully uploaded <s:property value="myFileFileName"/>
</body>
</html>