Browse Source

Fixed various code examples in documentation

Issue: SPR-13666
Issue: SPR-13485
Issue: SPR-10474
pull/931/head
Juergen Hoeller 10 years ago
parent
commit
48838d48d2
  1. 4
      spring-web/src/main/java/org/springframework/http/RequestEntity.java
  2. 2
      src/asciidoc/appendix.adoc
  3. 21
      src/asciidoc/index.adoc
  4. 8
      src/test/resources/log4j.properties

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

@ -33,14 +33,14 @@ import org.springframework.util.ObjectUtils; @@ -33,14 +33,14 @@ import org.springframework.util.ObjectUtils;
* {@link org.springframework.web.client.RestTemplate#exchange(RequestEntity, Class) exchange()}:
* <pre class="code">
* MyRequest body = ...
* RequestEntity&lt;MyRequest&gt; request = RequestEntity.post(new URI(&quot;http://example.com/bar&quot;).accept(MediaType.APPLICATION_JSON).body(body);
* RequestEntity&lt;MyRequest&gt; request = RequestEntity.post(new URI(&quot;http://example.com/bar&quot;)).accept(MediaType.APPLICATION_JSON).body(body);
* ResponseEntity&lt;MyResponse&gt; response = template.exchange(request, MyResponse.class);
* </pre>
*
* <p>If you would like to provide a URI template with variables, consider using
* {@link org.springframework.web.util.UriTemplate}:
* <pre class="code">
* URI uri = new UriTemplate(&quot;http://example.com/{foo}&quot;").expand(&quot;bar&quot;);
* URI uri = new UriTemplate(&quot;http://example.com/{foo}&quot;).expand(&quot;bar&quot;);
* RequestEntity&lt;MyRequest&gt; request = RequestEntity.post(uri).accept(MediaType.APPLICATION_JSON).body(body);
* </pre>
*

2
src/asciidoc/appendix.adoc

@ -4506,7 +4506,7 @@ escaping. Modeled after the JSTL c:url tag with backwards compatibility in mind. @@ -4506,7 +4506,7 @@ escaping. Modeled after the JSTL c:url tag with backwards compatibility in mind.
|===
| Attribute| Required?| Runtime Expression?| Description
| url
| value
| true
| true
| The URL to build. This value can include template {placeholders} that are replaced

21
src/asciidoc/index.adoc

@ -9130,13 +9130,14 @@ The following table lists features provided by the `BeanFactory` and @@ -9130,13 +9130,14 @@ The following table lists features provided by the `BeanFactory` and
| Yes
|===
To explicitly register a bean post-processor with a `BeanFactory` implementation, you
must write code like this:
To explicitly register a bean post-processor with a `BeanFactory` implementation,
you need to write code like this:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
ConfigurableBeanFactory factory = new XmlBeanFactory(...);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
// populate the factory with bean definitions
// now register any needed BeanPostProcessor instances
MyBeanPostProcessor postProcessor = new MyBeanPostProcessor();
@ -9151,7 +9152,9 @@ implementation, you must write code like this: @@ -9151,7 +9152,9 @@ implementation, you must write code like this:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource("beans.xml"));
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
reader.loadBeanDefinitions(new FileSystemResource("beans.xml"));
// bring in some property values from a Properties file
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
@ -30677,7 +30680,7 @@ also <<mvc-config-content-negotiation>> for content negotiation configuration. @@ -30677,7 +30680,7 @@ also <<mvc-config-content-negotiation>> for content negotiation configuration.
[[mvc-ann-requestmapping-rfd]]
==== Suffix Suffix Pattern Matching and RFD
==== Suffix Pattern Matching and RFD
Reflected file download (RFD) attack was first described in a
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: @@ -30717,7 +30720,7 @@ Below are additional recommendations from the report:
For an example of how to do that with Spring see https://github.com/rwinch/spring-jackson-owasp[spring-jackson-owasp].
* Configure suffix pattern matching to be turned off or restricted to explicitly
registered suffixes only.
* Configure content negotiation with the properties “useJaf” and “ignoreUknownPathExtension”
* Configure content negotiation with the properties "useJaf" and "ignoreUnknownPathExtensions"
set to false which would result in a 406 response for URLs with unknown extensions.
Note however that this may not be an option if URLs are naturally expected to have
a dot towards the end.
@ -47560,13 +47563,13 @@ default). Here you can see what methods are available for `Trigger` implementati @@ -47560,13 +47563,13 @@ default). Here you can see what methods are available for `Trigger` implementati
Spring provides two implementations of the `Trigger` interface. The most interesting one
is the `CronTrigger`. It enables the scheduling of tasks based on cron expressions. For
example the following task is being scheduled to run 15 minutes past each hour but only
example, the following task is being scheduled to run 15 minutes past each hour but only
during the 9-to-5 "business hours" on weekdays.
[source,java,indent=0]
[subs="verbatim"]
----
scheduler.schedule(task, new CronTrigger("* 15 9-17 * * MON-FRI"));
scheduler.schedule(task, new CronTrigger("0 15 9-17 * * MON-FRI"));
----
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 @@ -47578,7 +47581,7 @@ fixed-delay, those methods should be used directly whenever possible. The value
the `Trigger` abstraction. For example, it may be convenient to allow periodic triggers,
cron-based triggers, and even custom trigger implementations to be used interchangeably.
Such a component could take advantage of dependency injection so that such `Triggers`
could be configured externally.
could be configured externally and therefore easily modified or extended.

8
src/test/resources/log4j.properties

@ -3,11 +3,3 @@ log4j.appender.console.layout=org.apache.log4j.PatternLayout @@ -3,11 +3,3 @@ log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%c] - %m%n
log4j.rootCategory=WARN, console
log4j.logger.org.springframework.beans=WARN
log4j.logger.org.springframework.binding=DEBUG
log4j.logger.org.springframework.beans.factory.xml.XmlBeanFactory=ERROR
log4j.logger.org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator=TRACE
#log4j.logger.org.springframework=TRACE

Loading…
Cancel
Save