Fix some typos and mistakes in ref docs
Closes gh-27388
This commit is contained in:
committed by
Sam Brannen
parent
674dc2f203
commit
c46cc666d6
@@ -29,12 +29,12 @@ entry points into a server-side application, and it delegates to service objects
|
||||
(facades) that are defined in a service layer to satisfy business-specific (and
|
||||
presentation-technology agnostic) use cases. In Spring, these service objects, any other
|
||||
business-specific objects, data-access objects, and others exist in a distinct "`business
|
||||
context`", which contains no web or presentation layer objects (presentation objects
|
||||
,such as Spring MVC controllers, are typically configured in a distinct "`presentation
|
||||
context`", which contains no web or presentation layer objects (presentation objects,
|
||||
such as Spring MVC controllers, are typically configured in a distinct "`presentation
|
||||
context`"). This section details how you can configure a Spring container (a
|
||||
`WebApplicationContext`) that contains all of the 'business beans' in your application.
|
||||
|
||||
Moving on to specifics, all you one need to do is declare a
|
||||
Moving on to specifics, all you need to do is declare a
|
||||
{api-spring-framework}/web/context/ContextLoaderListener.html[`ContextLoaderListener`]
|
||||
in the standard Java EE servlet `web.xml` file of your web application and add a
|
||||
`contextConfigLocation`<context-param/> section (in the same file) that defines which
|
||||
|
||||
@@ -95,8 +95,8 @@ You can shorten it further still with a full URI template, as the following exam
|
||||
.Kotlin
|
||||
----
|
||||
val uri = UriComponentsBuilder
|
||||
.fromUriString("https://example.com/hotels/{hotel}?q={q}")
|
||||
.build("Westin", "123")
|
||||
.fromUriString("https://example.com/hotels/{hotel}?q={q}")
|
||||
.build("Westin", "123")
|
||||
----
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ You can shorten it further still with a full URI template, as the following exam
|
||||
----
|
||||
|
||||
The `WebClient` and the `RestTemplate` expand and encode URI templates internally through
|
||||
the `UriBuilderFactory` strategy. Both can be configured with a custom strategy.
|
||||
the `UriBuilderFactory` strategy. Both can be configured with a custom strategy,
|
||||
as the following example shows:
|
||||
|
||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
|
||||
|
||||
@@ -232,7 +232,7 @@ Java 8+. Using the latest update release available is highly recommended.
|
||||
line should be added for Kotlin script support. See
|
||||
https://github.com/sdeleuze/kotlin-script-templating[this example] for more detail.
|
||||
|
||||
You need to have the script templating library. One way to do that for Javascript is
|
||||
You need to have the script templating library. One way to do that for JavaScript is
|
||||
through https://www.webjars.org/[WebJars].
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ Each `HandlerMapping` can be
|
||||
{api-spring-framework}/web/servlet/handler/AbstractHandlerMapping.html#setCorsConfigurations-java.util.Map-[configured]
|
||||
individually with URL pattern-based `CorsConfiguration` mappings. In most cases, applications
|
||||
use the MVC Java configuration or the XML namespace to declare such mappings, which results
|
||||
in a single global map being passed to all `HandlerMappping` instances.
|
||||
in a single global map being passed to all `HandlerMapping` instances.
|
||||
|
||||
You can combine global CORS configuration at the `HandlerMapping` level with more
|
||||
fine-grained, handler-level CORS configuration. For example, annotated controllers can use
|
||||
|
||||
@@ -103,7 +103,7 @@ as the following example shows:
|
||||
|
||||
|
||||
If you register the `RouterFunction` as a bean, for instance by exposing it in a
|
||||
@Configuration class, it will be auto-detected by the servlet, as explained in <<webmvc-fn-running>>.
|
||||
`@Configuration` class, it will be auto-detected by the servlet, as explained in <<webmvc-fn-running>>.
|
||||
|
||||
|
||||
|
||||
@@ -475,7 +475,7 @@ For instance, the router function builder offers the method `GET(String, Handler
|
||||
Besides HTTP method-based mapping, the route builder offers a way to introduce additional
|
||||
predicates when mapping to requests.
|
||||
For each HTTP method there is an overloaded variant that takes a `RequestPredicate` as a
|
||||
parameter, though which additional constraints can be expressed.
|
||||
parameter, through which additional constraints can be expressed.
|
||||
|
||||
|
||||
[[webmvc-fn-predicates]]
|
||||
|
||||
@@ -615,7 +615,7 @@ Java 8+. Using the latest update release available is highly recommended.
|
||||
line should be added for Kotlin script support. See
|
||||
https://github.com/sdeleuze/kotlin-script-templating[this example] for more details.
|
||||
|
||||
You need to have the script templating library. One way to do that for Javascript is
|
||||
You need to have the script templating library. One way to do that for JavaScript is
|
||||
through https://www.webjars.org/[WebJars].
|
||||
|
||||
|
||||
@@ -1697,7 +1697,7 @@ located in the `WEB-INF/defs` directory. At initialization of the `WebApplicatio
|
||||
the files are loaded, and the definitions factory are initialized. After that has
|
||||
been done, the Tiles included in the definition files can be used as views within your
|
||||
Spring web application. To be able to use the views, you have to have a `ViewResolver`
|
||||
as with any other view technology in Spring : typically a convenient `TilesViewResolver`.
|
||||
as with any other view technology in Spring: typically a convenient `TilesViewResolver`.
|
||||
|
||||
You can specify locale-specific Tiles definitions by adding an underscore and then
|
||||
the locale, as the following example shows:
|
||||
|
||||
@@ -580,12 +580,12 @@ itself, excluding the `contextPath` and any `servletMapping` prefix, if present.
|
||||
|
||||
The `servletPath` and `pathInfo` are decoded and that makes them impossible to compare
|
||||
directly to the full `requestURI` in order to derive the lookupPath and that makes it
|
||||
necessary to decode the `requestUri`. However this introduces its own issues because the
|
||||
necessary to decode the `requestURI`. However this introduces its own issues because the
|
||||
path may contain encoded reserved characters such as `"/"` or `";"` that can in turn
|
||||
alter the structure of the path after they are decoded which can also lead to security
|
||||
issues. In addition, Servlet containers may normalize the `servletPath` to varying
|
||||
degrees which makes it further impossible to perform `startsWith` comparisons against
|
||||
the `requestUri`.
|
||||
the `requestURI`.
|
||||
|
||||
This is why it is best to avoid reliance on the `servletPath` which comes with the
|
||||
prefix-based `servletPath` mapping type. If the `DispatcherServlet` is mapped as the
|
||||
@@ -597,7 +597,7 @@ a `UrlPathHelper` with `alwaysUseFullPath=true` via <<mvc-config-path-matching>>
|
||||
the MVC config.
|
||||
|
||||
Fortunately the default Servlet mapping `"/"` is a good choice. However, there is still
|
||||
an issue in that the `requestUri` needs to be decoded to make it possible to compare to
|
||||
an issue in that the `requestURI` needs to be decoded to make it possible to compare to
|
||||
controller mappings. This is again undesirable because of the potential to decode
|
||||
reserved characters that alter the path structure. If such characters are not expected,
|
||||
then you can reject them (like the Spring Security HTTP firewall), or you can configure
|
||||
@@ -787,7 +787,7 @@ The following table provides more details on the `ViewResolver` hierarchy:
|
||||
you can use the `removeFromCache(String viewName, Locale loc)` method.
|
||||
|
||||
| `UrlBasedViewResolver`
|
||||
| Simple implementation of the `ViewResolver` interface that affects the direct
|
||||
| Simple implementation of the `ViewResolver` interface that effects the direct
|
||||
resolution of logical view names to URLs without an explicit mapping definition.
|
||||
This is appropriate if your logical names match the names of your view resources
|
||||
in a straightforward manner, without the need for arbitrary mappings.
|
||||
@@ -1545,8 +1545,8 @@ There are also HTTP method specific shortcut variants of `@RequestMapping`:
|
||||
|
||||
The shortcuts are <<mvc-ann-requestmapping-composed>> that are provided because,
|
||||
arguably, most controller methods should be mapped to a specific HTTP method versus
|
||||
using `@RequestMapping`, which, by default, matches to all HTTP methods. At the same,
|
||||
a `@RequestMapping` is still needed at the class level to express shared mappings.
|
||||
using `@RequestMapping`, which, by default, matches to all HTTP methods.
|
||||
A `@RequestMapping` is still needed at the class level to express shared mappings.
|
||||
|
||||
The following example has type and method level mappings:
|
||||
|
||||
@@ -1723,7 +1723,7 @@ one of the following depending on whether use of parsed `PathPattern` is enabled
|
||||
* {api-spring-framework}/web/util/pattern/PathPattern.html#SPECIFICITY_COMPARATOR[`PathPattern.SPECIFICITY_COMPARATOR`]
|
||||
* {api-spring-framework}/util/AntPathMatcher.html#getPatternComparator-java.lang.String-[`AntPathMatcher.getPatternComparator(String path)`]
|
||||
|
||||
Both help to sorts patterns with more specific ones on top. A pattern is less specific if
|
||||
Both help to sort patterns with more specific ones on top. A pattern is less specific if
|
||||
it has a lower count of URI variables (counted as 1), single wildcards (counted as 1),
|
||||
and double wildcards (counted as 2). Given an equal score, the longer pattern is chosen.
|
||||
Given the same score and length, the pattern with more URI variables than wildcards is
|
||||
@@ -1752,7 +1752,7 @@ using the `Accept` header should be the preferred choice.
|
||||
Over time, the use of file name extensions has proven problematic in a variety of ways.
|
||||
It can cause ambiguity when overlain with the use of URI variables, path parameters, and
|
||||
URI encoding. Reasoning about URL-based authorization
|
||||
and security (see next section for more details) also become more difficult.
|
||||
and security (see next section for more details) also becomes more difficult.
|
||||
|
||||
To completely disable the use of path extensions in versions prior to 5.3, set the following:
|
||||
|
||||
@@ -2171,7 +2171,7 @@ and others) and is equivalent to `required=false`.
|
||||
| If a method argument is not matched to any of the earlier values in this table and it is
|
||||
a simple type (as determined by
|
||||
{api-spring-framework}/beans/BeanUtils.html#isSimpleProperty-java.lang.Class-[BeanUtils#isSimpleProperty],
|
||||
it is a resolved as a `@RequestParam`. Otherwise, it is resolved as a `@ModelAttribute`.
|
||||
it is resolved as a `@RequestParam`. Otherwise, it is resolved as a `@ModelAttribute`.
|
||||
|===
|
||||
|
||||
|
||||
@@ -2300,7 +2300,7 @@ argument as `@Nullable`.
|
||||
====
|
||||
As of 5.3, non-null arguments will be enforced even after type conversion. If your handler
|
||||
method intends to accept a null value as well, either declare your argument as `@Nullable`
|
||||
or mark it as `required=false` in the corresponding `@RequestParam` etc annotation. This is
|
||||
or mark it as `required=false` in the corresponding `@RequestParam`, etc. annotation. This is
|
||||
a best practice and the recommended solution for regressions encountered in a 5.3 upgrade.
|
||||
|
||||
Alternatively, you may specifically handle e.g. the resulting `MissingPathVariableException`
|
||||
@@ -2777,8 +2777,8 @@ alternatively, set `@ModelAttribute(binding=false)`, as the following example sh
|
||||
<1> Setting `@ModelAttribute(binding=false)`.
|
||||
|
||||
You can automatically apply validation after data binding by adding the
|
||||
`javax.validation.Valid` annotation or Spring's `@Validated` annotation (
|
||||
<<core.adoc#validation-beanvalidation, Bean Validation>> and
|
||||
`javax.validation.Valid` annotation or Spring's `@Validated` annotation
|
||||
(<<core.adoc#validation-beanvalidation, Bean Validation>> and
|
||||
<<core.adoc#validation, Spring validation>>). The following example shows how to do so:
|
||||
|
||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
|
||||
@@ -2841,7 +2841,7 @@ The following example uses the `@SessionAttributes` annotation:
|
||||
----
|
||||
@Controller
|
||||
@SessionAttributes("pet") // <1>
|
||||
public class EditPetForm {
|
||||
class EditPetForm {
|
||||
// ...
|
||||
}
|
||||
----
|
||||
@@ -2866,9 +2866,8 @@ storage, as the following example shows:
|
||||
if (errors.hasErrors) {
|
||||
// ...
|
||||
}
|
||||
status.setComplete(); // <2>
|
||||
// ...
|
||||
}
|
||||
status.setComplete(); // <2>
|
||||
// ...
|
||||
}
|
||||
}
|
||||
----
|
||||
@@ -4357,7 +4356,7 @@ Spring MVC has an extensive integration with Servlet 3.0 asynchronous request
|
||||
<<mvc-ann-async-processing,processing>>:
|
||||
|
||||
* <<mvc-ann-async-deferredresult, `DeferredResult`>> and <<mvc-ann-async-callable, `Callable`>>
|
||||
return values in controller methods and provide basic support for a single asynchronous
|
||||
return values in controller methods provide basic support for a single asynchronous
|
||||
return value.
|
||||
* Controllers can <<mvc-ann-async-http-streaming,stream>> multiple values, including
|
||||
<<mvc-ann-async-sse, SSE>> and <<mvc-ann-async-output-stream, raw data>>.
|
||||
@@ -4889,7 +4888,7 @@ use case-oriented approach that focuses on the common scenarios:
|
||||
val ccCustom = CacheControl.maxAge(10, TimeUnit.DAYS).noTransform().cachePublic()
|
||||
----
|
||||
|
||||
`WebContentGenerator` also accept a simpler `cachePeriod` property (defined in seconds) that
|
||||
`WebContentGenerator` also accepts a simpler `cachePeriod` property (defined in seconds) that
|
||||
works as follows:
|
||||
|
||||
* A `-1` value does not generate a `Cache-Control` response header.
|
||||
@@ -4941,7 +4940,7 @@ settings to a `ResponseEntity`, as the following example shows:
|
||||
}
|
||||
----
|
||||
|
||||
The preceding example sends an 304 (NOT_MODIFIED) response with an empty body if the comparison
|
||||
The preceding example sends a 304 (NOT_MODIFIED) response with an empty body if the comparison
|
||||
to the conditional request headers indicates that the content has not changed. Otherwise, the
|
||||
`ETag` and `Cache-Control` headers are added to the response.
|
||||
|
||||
@@ -5104,6 +5103,7 @@ following example shows:
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
class WebConfig : WebMvcConfigurer {
|
||||
|
||||
// Implement configuration methods...
|
||||
}
|
||||
----
|
||||
|
||||
@@ -1118,7 +1118,7 @@ Contract for sending a message that enables loose coupling between producers and
|
||||
`SubscribableChannel` that uses an `Executor` for delivering messages.
|
||||
|
||||
Both the Java configuration (that is, `@EnableWebSocketMessageBroker`) and the XML namespace configuration
|
||||
(that is,`<websocket:message-broker>`) use the preceding components to assemble a message
|
||||
(that is, `<websocket:message-broker>`) use the preceding components to assemble a message
|
||||
workflow. The following diagram shows the components used when the simple built-in message
|
||||
broker is enabled:
|
||||
|
||||
@@ -1191,7 +1191,7 @@ is established, STOMP frames begin to flow on it.
|
||||
. The client sends a SUBSCRIBE frame with a destination header of `/topic/greeting`. Once received
|
||||
and decoded, the message is sent to the `clientInboundChannel` and is then routed to the
|
||||
message broker, which stores the client subscription.
|
||||
. The client sends a aSEND frame to `/app/greeting`. The `/app` prefix helps to route it to
|
||||
. The client sends a SEND frame to `/app/greeting`. The `/app` prefix helps to route it to
|
||||
annotated controllers. After the `/app` prefix is stripped, the remaining `/greeting`
|
||||
part of the destination is mapped to the `@MessageMapping` method in `GreetingController`.
|
||||
. The value returned from `GreetingController` is turned into a Spring `Message` with
|
||||
@@ -1768,7 +1768,7 @@ WebSocket and SockJS requests.
|
||||
|
||||
Therefore, applications that wish to avoid the use of cookies may not have any good
|
||||
alternatives for authentication at the HTTP protocol level. Instead of using cookies,
|
||||
they may prefer to authenticate with headers at the STOMP messaging protocol level
|
||||
they may prefer to authenticate with headers at the STOMP messaging protocol level.
|
||||
Doing so requires two simple steps:
|
||||
|
||||
. Use the STOMP client to pass authentication headers at connect time.
|
||||
|
||||
Reference in New Issue
Block a user