Skip to content

Commit 48838d4

Browse files
committed
Fixed various code examples in documentation
Issue: SPR-13666 Issue: SPR-13485 Issue: SPR-10474
1 parent 5d6aab3 commit 48838d4

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

spring-web/src/main/java/org/springframework/http/RequestEntity.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
* {@link org.springframework.web.client.RestTemplate#exchange(RequestEntity, Class) exchange()}:
3434
* <pre class="code">
3535
* MyRequest body = ...
36-
* RequestEntity&lt;MyRequest&gt; request = RequestEntity.post(new URI(&quot;http://example.com/bar&quot;).accept(MediaType.APPLICATION_JSON).body(body);
36+
* RequestEntity&lt;MyRequest&gt; request = RequestEntity.post(new URI(&quot;http://example.com/bar&quot;)).accept(MediaType.APPLICATION_JSON).body(body);
3737
* ResponseEntity&lt;MyResponse&gt; response = template.exchange(request, MyResponse.class);
3838
* </pre>
3939
*
4040
* <p>If you would like to provide a URI template with variables, consider using
4141
* {@link org.springframework.web.util.UriTemplate}:
4242
* <pre class="code">
43-
* URI uri = new UriTemplate(&quot;http://example.com/{foo}&quot;").expand(&quot;bar&quot;);
43+
* URI uri = new UriTemplate(&quot;http://example.com/{foo}&quot;).expand(&quot;bar&quot;);
4444
* RequestEntity&lt;MyRequest&gt; request = RequestEntity.post(uri).accept(MediaType.APPLICATION_JSON).body(body);
4545
* </pre>
4646
*

src/asciidoc/appendix.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -4506,7 +4506,7 @@ escaping. Modeled after the JSTL c:url tag with backwards compatibility in mind.
45064506
|===
45074507
| Attribute| Required?| Runtime Expression?| Description
45084508

4509-
| url
4509+
| value
45104510
| true
45114511
| true
45124512
| The URL to build. This value can include template {placeholders} that are replaced

src/asciidoc/index.adoc

+12-9
Original file line numberDiff line numberDiff line change
@@ -9130,13 +9130,14 @@ The following table lists features provided by the `BeanFactory` and
91309130
| Yes
91319131
|===
91329132

9133-
To explicitly register a bean post-processor with a `BeanFactory` implementation, you
9134-
must write code like this:
9133+
To explicitly register a bean post-processor with a `BeanFactory` implementation,
9134+
you need to write code like this:
91359135

91369136
[source,java,indent=0]
91379137
[subs="verbatim,quotes"]
91389138
----
9139-
ConfigurableBeanFactory factory = new XmlBeanFactory(...);
9139+
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
9140+
// populate the factory with bean definitions
91409141

91419142
// now register any needed BeanPostProcessor instances
91429143
MyBeanPostProcessor postProcessor = new MyBeanPostProcessor();
@@ -9151,7 +9152,9 @@ implementation, you must write code like this:
91519152
[source,java,indent=0]
91529153
[subs="verbatim,quotes"]
91539154
----
9154-
XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource("beans.xml"));
9155+
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
9156+
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
9157+
reader.loadBeanDefinitions(new FileSystemResource("beans.xml"));
91559158

91569159
// bring in some property values from a Properties file
91579160
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
@@ -30677,7 +30680,7 @@ also <<mvc-config-content-negotiation>> for content negotiation configuration.
3067730680

3067830681

3067930682
[[mvc-ann-requestmapping-rfd]]
30680-
==== Suffix Suffix Pattern Matching and RFD
30683+
==== Suffix Pattern Matching and RFD
3068130684

3068230685
Reflected file download (RFD) attack was first described in a
3068330686
https://www.trustwave.com/Resources/SpiderLabs-Blog/Reflected-File-Download---A-New-Web-Attack-Vector/[paper by Trustwave]
@@ -30717,7 +30720,7 @@ Below are additional recommendations from the report:
3071730720
For an example of how to do that with Spring see https://github.com/rwinch/spring-jackson-owasp[spring-jackson-owasp].
3071830721
* Configure suffix pattern matching to be turned off or restricted to explicitly
3071930722
registered suffixes only.
30720-
* Configure content negotiation with the properties useJaf and “ignoreUknownPathExtension”
30723+
* Configure content negotiation with the properties "useJaf" and "ignoreUnknownPathExtensions"
3072130724
set to false which would result in a 406 response for URLs with unknown extensions.
3072230725
Note however that this may not be an option if URLs are naturally expected to have
3072330726
a dot towards the end.
@@ -47560,13 +47563,13 @@ default). Here you can see what methods are available for `Trigger` implementati
4756047563

4756147564
Spring provides two implementations of the `Trigger` interface. The most interesting one
4756247565
is the `CronTrigger`. It enables the scheduling of tasks based on cron expressions. For
47563-
example the following task is being scheduled to run 15 minutes past each hour but only
47566+
example, the following task is being scheduled to run 15 minutes past each hour but only
4756447567
during the 9-to-5 "business hours" on weekdays.
4756547568

4756647569
[source,java,indent=0]
4756747570
[subs="verbatim"]
4756847571
----
47569-
scheduler.schedule(task, new CronTrigger("* 15 9-17 * * MON-FRI"));
47572+
scheduler.schedule(task, new CronTrigger("0 15 9-17 * * MON-FRI"));
4757047573
----
4757147574

4757247575
The other out-of-the-box implementation is a `PeriodicTrigger` that accepts a fixed
@@ -47578,7 +47581,7 @@ fixed-delay, those methods should be used directly whenever possible. The value
4757847581
the `Trigger` abstraction. For example, it may be convenient to allow periodic triggers,
4757947582
cron-based triggers, and even custom trigger implementations to be used interchangeably.
4758047583
Such a component could take advantage of dependency injection so that such `Triggers`
47581-
could be configured externally.
47584+
could be configured externally and therefore easily modified or extended.
4758247585

4758347586

4758447587

src/test/resources/log4j.properties

-8
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,3 @@ log4j.appender.console.layout=org.apache.log4j.PatternLayout
33
log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%c] - %m%n
44

55
log4j.rootCategory=WARN, console
6-
log4j.logger.org.springframework.beans=WARN
7-
log4j.logger.org.springframework.binding=DEBUG
8-
log4j.logger.org.springframework.beans.factory.xml.XmlBeanFactory=ERROR
9-
10-
log4j.logger.org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator=TRACE
11-
12-
#log4j.logger.org.springframework=TRACE
13-

0 commit comments

Comments
 (0)