struts2和springmvc混合项目,上传文件报错

问题

控制器的方法代码

java 复制代码
@PostMapping("/uploadExcel2")
public String uploadExcel2(@RequestParam("file") MultipartFile file) {

报错

HTTP状态 400 - 错误的请求


类型 状态报告

消息 Required request part 'file' is not present

描述 由于被认为是客户端对错误(例如:畸形的请求语法、无效的请求信息帧或者虚拟的请求路由),服务器无法或不会处理当前请求。


Apache Tomcat/8.5.99

原因

因为struts2先拦截了,先读了文件流

导致spring读不到文件流

解决方法

struts2排除掉springmvc请求地址


配置文件

struts.properties

properties 复制代码
struts.action.excludePattern = /rest/xxx
相关推荐
leikooo1 小时前
在 Spring AI 中自定义 Tool 调用返回值——实现 TodoList 提醒注入
spring
码喽7号2 小时前
Springboot学习五:MybatisPlus的快速上手
spring boot·学习·spring
weixin_704266052 小时前
事务管理全解析:从ACID到Spring实现
java·数据库·spring
YmaxU4 小时前
SpringAIAlibaba学习使用 ---Graph
java·学习·spring·ai
StackNoOverflow4 小时前
Spring整合MyBatis与事务管理详解(第三部分)
java·spring
NE_STOP4 小时前
SpringCloud--快速上手Eureka注册中心
spring
老友@4 小时前
微服务全面解析:架构、组件与底层原理
数据库·spring·oracle
014-code5 小时前
Spring 事务原理深度解析
java·数据库·spring·oracle
没有bug.的程序员6 小时前
黑客僵尸网络的降维打击:Spring Cloud Gateway 自定义限流剿杀 Sentinel 内存黑洞
java·网络·spring·gateway·sentinel
qq_411262426 小时前
AP模式中修改下wifi名称就无法连接了,分析一下
java·前端·spring