Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
26bb3a08
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
26bb3a08
编写于
3月 19, 2018
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve docs on enabling Servlet 3 multipart
上级
8651b8d4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
6 deletion
+34
-6
spring-web/src/main/java/org/springframework/web/multipart/support/StandardServletMultipartResolver.java
...b/multipart/support/StandardServletMultipartResolver.java
+13
-1
src/docs/asciidoc/web/webmvc.adoc
src/docs/asciidoc/web/webmvc.adoc
+21
-5
未找到文件。
spring-web/src/main/java/org/springframework/web/multipart/support/StandardServletMultipartResolver.java
浏览文件 @
26bb3a08
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -41,6 +41,18 @@ import org.springframework.web.multipart.MultipartResolver;
* storage locations need to be applied at that servlet registration level;
* Servlet 3.0 does not allow for them to be set at the MultipartResolver level.
*
* <pre class="code">
* public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
* // ...
* @Override
* protected void customizeRegistration(ServletRegistration.Dynamic registration) {
*
* // Optionally also set maxFileSize, maxRequestSize, fileSizeThreshold
* registration.setMultipartConfig(new MultipartConfigElement("/tmp"));
* }
* }
* </pre>
*
* @author Juergen Hoeller
* @since 3.1
* @see #setResolveLazily
...
...
src/docs/asciidoc/web/webmvc.adoc
浏览文件 @
26bb3a08
...
...
@@ -999,11 +999,27 @@ have `commons-fileupload` as a dependency on your classpath.
[[mvc-multipart-resolver-standard]]
==== Servlet 3.0
To use Servlet 3.0 multipart support, you need to register the `DispatcherServlet`
accordingly. In programmatic Servlet registration, set a `MultipartConfigElement` on the
Servlet registration. In `web.xml`, add a `"<multipart-config>"` section. Configuration
settings such as maximum sizes or storage locations need to be applied at this level
since Servlet 3.0 API does not make it possible for the `MultipartResolver` to do so.
Servlet 3.0 multipart parsing needs to be enabled through Servlet container configuration:
* in Java, set a `MultipartConfigElement` on the Servlet registration.
* in `web.xml`, add a `"<multipart-config>"` section to the servlet declaration.
[source,java,indent=0]
[subs="verbatim,quotes"]
----
public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
// ...
@Override
protected void customizeRegistration(ServletRegistration.Dynamic registration) {
// Optionally also set maxFileSize, maxRequestSize, fileSizeThreshold
registration.setMultipartConfig(new MultipartConfigElement("/tmp"));
}
}
----
Once the Servlet 3.0 configuration is in place, simply add a bean of type
`StandardServletMultipartResolver` with the name `multipartResolver`.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录