📄 uploadaction.java
字号:
package com.briup;import java.io.*;import org.apache.struts2.ServletActionContext;public class UploadAction { private File icon; private String iconFileName; //路径 /upload(“/”表示web应用下) ->/opt/tomcat/webapps/struts_jd0808a/upload private String savePath; public File getIcon() { return icon; } public void setIcon(File icon) { this.icon = icon; } public String getIconFileName() { return iconFileName; } public void setIconFileName(String iconFileName) { this.iconFileName = iconFileName; } public String getSavePath() { return ServletActionContext.getRequest().getSession().getServletContext().getRealPath(savePath); } public void setSavePath(String savePath) { this.savePath = savePath; } public String execute() throws Exception{ BufferedInputStream in=new BufferedInputStream(new FileInputStream(icon)); BufferedOutputStream out=new BufferedOutputStream(new FileOutputStream(getSavePath()+"/"+iconFileName)); byte[] buffer=new byte[1024]; int i=-1; while((i=in.read(buffer))!=-1){ out.write(buffer, 0, i); } out.close(); in.close(); return "success"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -