|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2017 the original author or authors. |
| 2 | + * Copyright 2012-2018 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
32 | 32 | * @author Sébastien Deleuze
|
33 | 33 | * @author Stephane Nicoll
|
34 | 34 | * @author Eddú Meléndez
|
| 35 | + * @author Brian Clozel |
35 | 36 | * @since 1.1
|
36 | 37 | */
|
37 | 38 | @ConfigurationProperties(prefix = "spring.mvc")
|
@@ -102,6 +103,10 @@ public class WebMvcProperties {
|
102 | 103 |
|
103 | 104 | private final View view = new View();
|
104 | 105 |
|
| 106 | + private final ContentNegotiation contentNegotiation = new ContentNegotiation(); |
| 107 | + |
| 108 | + private final PathMatch pathMatch = new PathMatch(); |
| 109 | + |
105 | 110 | public DefaultMessageCodesResolver.Format getMessageCodesResolverFormat() {
|
106 | 111 | return this.messageCodesResolverFormat;
|
107 | 112 | }
|
@@ -204,6 +209,14 @@ public View getView() {
|
204 | 209 | return this.view;
|
205 | 210 | }
|
206 | 211 |
|
| 212 | + public ContentNegotiation getContentNegotiation() { |
| 213 | + return this.contentNegotiation; |
| 214 | + } |
| 215 | + |
| 216 | + public PathMatch getPathMatch() { |
| 217 | + return this.pathMatch; |
| 218 | + } |
| 219 | + |
207 | 220 | public static class Async {
|
208 | 221 |
|
209 | 222 | /**
|
@@ -270,6 +283,84 @@ public void setSuffix(String suffix) {
|
270 | 283 |
|
271 | 284 | }
|
272 | 285 |
|
| 286 | + public static class ContentNegotiation { |
| 287 | + |
| 288 | + /** |
| 289 | + * Whether the path extension in the URL path should be used to determine |
| 290 | + * the requested media type. If enabled a request "/users.pdf" will be |
| 291 | + * interpreted as a request for "application/pdf" regardless of the 'Accept' header. |
| 292 | + */ |
| 293 | + private boolean favorPathExtension = false; |
| 294 | + |
| 295 | + /** |
| 296 | + * Whether a request parameter ("format" by default) should be used to |
| 297 | + * determine the requested media type. |
| 298 | + */ |
| 299 | + private boolean favorParameter = false; |
| 300 | + |
| 301 | + /** |
| 302 | + * Query parameter name to use when "favor-parameter" is enabled. |
| 303 | + */ |
| 304 | + private String parameterName; |
| 305 | + |
| 306 | + public boolean isFavorPathExtension() { |
| 307 | + return this.favorPathExtension; |
| 308 | + } |
| 309 | + |
| 310 | + public void setFavorPathExtension(boolean favorPathExtension) { |
| 311 | + this.favorPathExtension = favorPathExtension; |
| 312 | + } |
| 313 | + |
| 314 | + public boolean isFavorParameter() { |
| 315 | + return this.favorParameter; |
| 316 | + } |
| 317 | + |
| 318 | + public void setFavorParameter(boolean favorParameter) { |
| 319 | + this.favorParameter = favorParameter; |
| 320 | + } |
| 321 | + |
| 322 | + public String getParameterName() { |
| 323 | + return this.parameterName; |
| 324 | + } |
| 325 | + |
| 326 | + public void setParameterName(String parameterName) { |
| 327 | + this.parameterName = parameterName; |
| 328 | + } |
| 329 | + } |
| 330 | + |
| 331 | + public static class PathMatch { |
| 332 | + |
| 333 | + /** |
| 334 | + * Whether to use suffix pattern match (".*") when matching patterns to |
| 335 | + * requests. If enabled a method mapped to "/users" also matches to "/users.*". |
| 336 | + */ |
| 337 | + private boolean useSuffixPattern = false; |
| 338 | + |
| 339 | + /** |
| 340 | + * Whether suffix pattern matching should work only against path extensions |
| 341 | + * explicitly registered with "spring.mvc.media-types.*". |
| 342 | + * This is generally recommended to reduce ambiguity and to |
| 343 | + * avoid issues such as when a "." appears in the path for other reasons. |
| 344 | + */ |
| 345 | + private boolean useRegisteredSuffixPattern = false; |
| 346 | + |
| 347 | + public boolean isUseSuffixPattern() { |
| 348 | + return this.useSuffixPattern; |
| 349 | + } |
| 350 | + |
| 351 | + public void setUseSuffixPattern(boolean useSuffixPattern) { |
| 352 | + this.useSuffixPattern = useSuffixPattern; |
| 353 | + } |
| 354 | + |
| 355 | + public boolean isUseRegisteredSuffixPattern() { |
| 356 | + return this.useRegisteredSuffixPattern; |
| 357 | + } |
| 358 | + |
| 359 | + public void setUseRegisteredSuffixPattern(boolean useRegisteredSuffixPattern) { |
| 360 | + this.useRegisteredSuffixPattern = useRegisteredSuffixPattern; |
| 361 | + } |
| 362 | + } |
| 363 | + |
273 | 364 | public enum LocaleResolver {
|
274 | 365 |
|
275 | 366 | /**
|
|
0 commit comments