<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.i18n.encoding" value="utf-8"></constant>
<package name="test" namespace="/test" extends="struts-default">
<interceptors>
<interceptor name="myInterceptor" class="interceptor.MyInterceptor"></interceptor>
</interceptors>
<action name="tokenAction" class="action.TokenAction">
<interceptor-ref name="token"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="input" type="redirect">/index.jsp</result>
<result name="success">/success.jsp</result>
<result name="invalid.token">/error.jsp</result>
</action>
<action name="singleUploadAction" class="action.SingleUploadAction">
<interceptor-ref name="fileUpload"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="uploadSuccess">/uploadSuccess.jsp</result>
</action>
<action name="multiUploadAction" class="action.MultiUploadAction">
<interceptor-ref name="fileUploadStack"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="uploadSuccess">/uploadSuccess.jsp</result>
</action>
<action name="interceptorAction" class="action.InterceptorAction">
<interceptor-ref name="myInterceptor"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="success">/success.jsp</result>
</action>
</package>
</struts>
package action;
import com.opensymphony.xwork2.ActionSupport;
public class InterceptorAction extends ActionSupport {
public String test(){
System.out.println("action in");
return SUCCESS;
}
}
package action;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import javax.servlet.ServletContext;
import org.apache.struts2.util.ServletContextAware;
import com.opensymphony.xwork2.ActionSupport;
public class MultiUploadAction extends ActionSupport implements
ServletContextAware {
private File[] su;
private String[] suContentType;
private String[] suFileName;
private ServletContext context;
private String separator = File.separator;
private String directory = "file";
public String upload() throws Exception {
String realPath = context.getRealPath("");
File uploadDirectory = new File(realPath, directory);// 上传文件保存文件夹
if (!uploadDirectory.exists()) {
uploadDirectory.mkdir();
}
File uploadFile;
FileInputStream fis;
BufferedInputStream bis;
FileOutputStream fos;
BufferedOutputStream bos;
for (int i = 0; i < su.length; i++) {
uploadFile = new File(uploadDirectory, suFileName[i]);// 上传文件
fis = new FileInputStream(su[i]);// 读取源文件
bis = new BufferedInputStream(fis);// 缓冲流
fos = new FileOutputStream(uploadFile);// 上传文件
bos = new BufferedOutputStream(fos);// 缓冲流
int len = 0;
byte[] buff = new byte[1024 * 8];
while ((len = bis.read(buff)) != -1) {
bos.write(buff, 0, len);
bos.flush();
}
if (null != bos) {
bos.close();
}
if (null != fos) {
fos.close();
}
if (null != bis) {
bis.close();
}
if (null != fis) {
fis.close();
}
}
return "uploadSuccess";
}
public File[] getSu() {
return su;
}
public void setSu(File[] su) {
this.su = su;
}
public String[] getSuContentType() {
return suContentType;
}
public void setSuContentType(String[] suContentType) {
this.suContentType = suContentType;
}
public String[] getSuFileName() {
return suFileName;
}
public void setSuFileName(String[] suFileName) {
this.suFileName = suFileName;
}
public void setServletContext(ServletContext context) {
this.context = context;
}
}
package action;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import javax.servlet.ServletContext;
import org.apache.struts2.util.ServletContextAware;
import com.opensymphony.xwork2.ActionSupport;
public class SingleUploadAction extends ActionSupport implements
ServletContextAware {
private File su;
private String suContentType;
private String suFileName;
private ServletContext context;
private String separator = File.separator;
public String upload() throws Exception {
// 上传路径文件夹地址
String path = context.getRealPath("");
File uploadAddress = new File(path, "file");
if (!uploadAddress.exists()) {
uploadAddress.mkdir();
}
File uploadFile = new File(uploadAddress, suFileName);// 上传文件
FileInputStream fis = new FileInputStream(su);// 读取原始文件
BufferedInputStream bis = new BufferedInputStream(fis);// 缓冲流
FileOutputStream fos = new FileOutputStream(uploadFile);// 上传文件流
BufferedOutputStream bos = new BufferedOutputStream(fos);// 缓冲流
int len = 0;
byte[] buff = new byte[1024 * 8];
while ((len = bis.read(buff)) != -1) {
bos.write(buff, 0, len);
bos.flush();
}
bos.close();
fos.close();
bis.close();
fis.close();
return "uploadSuccess";
}
public File getSu() {
return su;
}
public void setSu(File su) {
this.su = su;
}
public String getSuContentType() {
return suContentType;
}
public void setSuContentType(String suContentType) {
this.suContentType = suContentType;
}
public String getSuFileName() {
return suFileName;
}
public void setSuFileName(String suFileName) {
this.suFileName = suFileName;
}
public void setServletContext(ServletContext context) {
this.context = context;
}
}
package action;
import com.opensymphony.xwork2.ActionSupport;
public class TokenAction extends ActionSupport {
private String username;
private String password;
public String init(){
return INPUT;
}
public String register() {
System.out.println("username : " + username);
System.out.println("password : " + password);
return SUCCESS;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
package interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
public class MyInterceptor implements Interceptor {
public void destroy() {
}
public void init() {
}
public String intercept(ActionInvocation invocation) throws Exception {
System.out.println("myInterceptor in ");
String result = invocation.invoke();
System.out.println(result);
System.out.println("myInterceptor out ");
return result;
}
}
package test;
public class Action {
public String test(){
System.out.println("action");
return "input";
}
}
package test;
import java.util.ArrayList;
import java.util.List;
public class ActionInvocation {
private List<Interceptor> interceptors = new ArrayList<Interceptor>();
private Action action = new Action();
public ActionInvocation(){
FirstInterceptor fi = new FirstInterceptor();
SecondInterceptor si = new SecondInterceptor();
interceptors.add(fi);
interceptors.add(si);
}
int index = -1;
String result;
public String invoke(){
index++;
if(index < interceptors.size()){
result = interceptors.get(index).interceptor(this);
}else{
result = action.test();
}
return result;
}
}
package test;
public class FirstInterceptor implements Interceptor {
public void destroy() {
}
public void init() {
}
public String interceptor(ActionInvocation invocation) {
System.out.println("1");
String result = invocation.invoke();
System.out.println(result);
System.out.println("-1");
return result;
}
}
package test;
public class InteceptorTest {
/**
* @param args
*/
public static void main(String[] args) {
ActionInvocation invocation = new ActionInvocation();
invocation.invoke();
}
}
package test;
public interface Interceptor {
public void destroy();
public void init();
public String interceptor(ActionInvocation invocation);
}
package test;
public class SecondInterceptor implements Interceptor {
public void destroy() {
}
public void init() {
}
public String interceptor(ActionInvocation invocation) {
System.out.println("2");
String result = invocation.invoke();
System.out.println(result);
System.out.println("-2");
return result;
}
}
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'error.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">
#num{
font-size:14px;
color:red;
font-weight:bold;
}
</style>
<script type="text/javascript" src="javascript/common.jsp"></script>
<script type="text/javascript">
function daojishi(){
document.getElementById("num").innerText = parseInt(document.getElementById("num").innerText) - 1;
if(parseInt(document.getElementById("num").innerText) == 0){
to("/index.jsp");
}
setTimeout(daojishi,1000);
}
window.onload = daojishi;
</script>
</head>
<body>
系统正在处理中...请勿重复提交 ! <span id="num" >5</span>秒后返回注册页面!
<a href="javascript:to('/index.jsp')">手动跳转</a>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<s:form action="test/tokenAction!register" theme="simple">
username: <s:textfield name="username"></s:textfield><br>
password: <s:password name="password"></s:password><br>;
<s:token></s:token>
<s:submit value="submit"></s:submit><br>
</s:form>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'success.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
success
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'upload.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<s:form action="test/singleUploadAction!upload" method="post" enctype="multipart/form-data">
<s:file name="su"></s:file>
<s:submit value="上传"></s:submit>
</s:form>
<s:form action="test/multiUploadAction!upload" method="post" enctype="multipart/form-data">
<s:file name="su"></s:file>
<s:file name="su"></s:file>
<s:file name="su"></s:file>
<s:file name="su"></s:file>
<s:submit value="上传"></s:submit>
</s:form>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'uploadSuccess.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<font color="red"><s:property value="suFileName"/></font>上传成功!
</body>
</html>
分享到:
相关推荐
基于transUnet和swinUnet的医学图像分割项目实验对比,包含完整代码,可以一键运行。评估指标包括dice、iou、recall、precision等
,stm32f030无感foc方案,资料包括原理图,pcb,源程序,观测器参数,电流环参数计算表格。
分布式电源DG选址定容优化及帕累托最优解集的粒子群算法研究,多目标粒子群算法 分布式电源 DG 定容选址 网损 成本 电压偏差 通过分布式能源的选址定容确定得到帕累托最优解集,然后选择最优值进行分析,程序采用改进粒子群算法, ,核心关键词:多目标粒子群算法; 分布式电源选址定容; 网损; 成本; 电压偏差; 帕累托最优解集。,改进粒子群算法在分布式电源选址定容中的应用:优化网损与成本,考虑电压偏差
交变磁场感应材料对沥青路面温度影响的研究,交变磁场下含感应材料沥青路面温度 ,交变磁场; 感应材料; 沥青路面; 温度; 变化; 加热效率,交变磁场对含感应材料沥青路面温度的影响研究
基于Comsol模拟的三层顶板随机裂隙浆液扩散模型:考虑重力影响的瞬态扩散规律分析,Comsol模拟,考虑三层顶板包含随机裂隙的浆液扩散模型,考虑浆液重力的影响,模型采用的DFN插件建立随机裂隙,采用达西定律模块中的储水模型为控制方程,分析不同注浆压力条件下的浆液扩散规律,建立瞬态模型 ,Comsol模拟; 随机裂隙浆液扩散模型; 浆液重力影响; DFN插件; 达西定律模块储水模型; 注浆压力条件; 浆液扩散规律; 瞬态模型,Comsol浆液扩散模型:随机裂隙下考虑重力的瞬态扩散分析
对于Sqlserver数据库只是提供了简单的图形化的导出导入工具,在实际的开发和生产环境不太可能让用户在图形化的界面选择移行的对象,进行移行。 我们在数据库的移行中也遇到这种问题,需要提供一个工具给客户使用。所以我们开发了针对SQLServer数据库的cmd形式导入导出的工具。在长期的实践中不断完善,基本可以实现Oracle的导入导出工具的80%的功能,也比较的稳定。有需要的可以下载使用,也可以提供定制化的服务
内容概要:本文介绍了DeepSeek模型在不同平台上部署的方法。首先阐述了基于Ollama的本地部署,包括Ollama的安装、模型拉取以及交互模式的使用。接着讲解了DeepSeek在移动设备(iOS和Android)上的部署细节:iPhone需要通过Safari安装快捷指令,配置API Key并通过快捷指令测试运行;Android则借助Termux安装必要组件,并手动搭建Ollama环境以加载和测试模型。最后详细叙述了基于Open WebUI部署的方式,涉及Ollama、Docker Desktop及Open WebUI的安装流程及其之间的配合使用来最终达成模型的成功部署。 适用人群:面向有兴趣了解或者实际操作DeepSeek模型跨平台部署的技术开发者、研究人员以及AI爱好者。 使用场景及目标:适用于希望利用DeepSeek模型快速构建本地化应用程序、开展实验研究的用户;具体目标为掌握DeepSeek模型在桌面系统(如Linux、macOS、Windows)、iOS和Android智能手机以及云端WebUI界面上的不同部署手段和技术。 其他说明:对于每种类型的部署都提供了详细的步骤指导,旨在帮助使用者顺利完成所需工具和环境的安装,并确保模型能够正常工作。文中给出的具体链接和命令行脚本,有助于降低初次接触者的上手难度,提升部署效率和成功率。此外,还强调了一些重要的配置注意事项,例如正确输入API key以及对Ollama的初始化检查等。
,FOC 无感 混合磁链观测器 电机控制 代码 PMSM MiniDD(直驱)电机变频无感程序,包含偏心,重量,共振等感知算法,所有算法都不基于库函数,MCU底层配置完全手写
nodejs010-nodejs-cmd-shim-1.1.0-4.1.el6.centos.alt.noarch.rpm
基于S7-200 PLC的交通灯倒计时控制及组态王界面实现原理图解析,S7-200 PLC和组态王交通灯带倒计时控制 923 47 带解释的梯形图接线图原理图图纸,io分配,组态画面 ,S7-200 PLC; 交通灯; 倒计时控制; 组态王; 梯形图接线图; IO分配; 组态画面,"S7-200 PLC与组态王交通灯倒计时控制:梯形图原理及IO分配详解"
西门子四轴卧加后处理系统:828D至840D兼容,四轴联动高效加工解决方案,支持图档处理及试看程序。,西门子四轴卧加后处理,支持828D~840D系统,支持四轴联动,可制制,看清楚联系,可提供图档处理试看程序 ,核心关键词:西门子四轴卧加后处理; 828D~840D系统支持; 四轴联动; 制程; 联系; 图档处理试看程序。,西门子四轴卧加后处理程序,支持多种系统与四轴联动
FPGA篮球赛事24秒倒计时计时器设计与实现(基于Verilog与VHDLL的优化对比),基于fpga篮球倒计时24s。 verilog和vhdl两个版本 ,基于FPGA篮球倒计时24s; Verilog版本; VHDL版本,FPGA篮球比赛倒计时24秒系统:Verilog与VHDL双版本实现
论生成式AI在大学生学习中的应用与伦理问题.pdf
免费JAVA毕业设计 2024成品源码+论文+数据库+启动教程 启动教程:https://www.bilibili.com/video/BV1SzbFe7EGZ 项目讲解视频:https://www.bilibili.com/video/BV1Tb421n72S 二次开发教程:https://www.bilibili.com/video/BV18i421i7Dx
"S7-200plc与MCGS智能居家控制系统的深度融合:组态画面、IO分配与梯形图接线图原理详解",No.63 S7-200plc和 MCGS智能居家控制系统组态 带解释的梯形图接线图原理图图纸,io分配,组态画面 ,核心关键词:S7-200plc; MCGS智能居家控制系统; 梯形图接线图原理图; io分配; 组态画面。,"S7-200 PLC与MCGS智能居家系统组态及梯形图原理图解析"
方便暖通工程师及板换用户了解艾齐尔板式换热器选型计算,免费使用。
《四层三列堆垛式立体库控制系统:带解释的梯形图接线原理图及IO分配与组态画面详解》,4x3堆垛式立体库4层3列四层三列书架式立体库控制系统 带解释的梯形图接线图原理图图纸,io分配,组态画面 ,立体库; 堆垛式; 控制系统; 梯形图; 接线图; 原理图; IO分配; 组态画面,"立体库控制系统原理图:四层三列堆垛式书架的IO分配与组态画面"
免费JAVA毕业设计 2024成品源码+论文+数据库+启动教程 启动教程:https://www.bilibili.com/video/BV1SzbFe7EGZ 项目讲解视频:https://www.bilibili.com/video/BV1Tb421n72S 二次开发教程:https://www.bilibili.com/video/BV18i421i7Dx
免费JAVA毕业设计 2024成品源码+论文+数据库+启动教程 启动教程:https://www.bilibili.com/video/BV1SzbFe7EGZ 项目讲解视频:https://www.bilibili.com/video/BV1Tb421n72S 二次开发教程:https://www.bilibili.com/video/BV18i421i7Dx
免费JAVA毕业设计 2024成品源码+论文+数据库+启动教程 启动教程:https://www.bilibili.com/video/BV1SzbFe7EGZ 项目讲解视频:https://www.bilibili.com/video/BV1Tb421n72S 二次开发教程:https://www.bilibili.com/video/BV18i421i7Dx