Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
8e5244ac
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,发现更多精彩内容 >>
提交
8e5244ac
编写于
7月 23, 2015
作者:
S
Sebastien Deleuze
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish script templating documentation
上级
2a995ae2
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
21 addition
and
9 deletion
+21
-9
spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateConfigurer.java
...ork/web/servlet/view/script/ScriptTemplateConfigurer.java
+7
-7
spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc-4.2.xsd
...org/springframework/web/servlet/config/spring-mvc-4.2.xsd
+3
-1
src/asciidoc/web-view.adoc
src/asciidoc/web-view.adoc
+11
-1
未找到文件。
spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateConfigurer.java
浏览文件 @
8e5244ac
...
@@ -26,10 +26,8 @@ import javax.script.ScriptEngine;
...
@@ -26,10 +26,8 @@ import javax.script.ScriptEngine;
* <pre class="code">
* <pre class="code">
*
*
* // Add the following to an @Configuration class
* // Add the following to an @Configuration class
*
* @Bean
* @Bean
* public ScriptTemplateConfigurer mustacheConfigurer() {
* public ScriptTemplateConfigurer mustacheConfigurer() {
*
* ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
* ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
* configurer.setEngineName("nashorn");
* configurer.setEngineName("nashorn");
* configurer.setScripts("mustache.js");
* configurer.setScripts("mustache.js");
...
@@ -39,9 +37,9 @@ import javax.script.ScriptEngine;
...
@@ -39,9 +37,9 @@ import javax.script.ScriptEngine;
* }
* }
* </pre>
* </pre>
*
*
* <p><b>NOTE:</b> It is possible to use non thread-safe script engines
and
* <p><b>NOTE:</b> It is possible to use non thread-safe script engines
with
* templating libraries
, like Handlebars or React running on Nashorn, by setting
* templating libraries
not designed for concurrency, like Handlebars or React running on
* the {@link #setSharedEngine sharedEngine} property to {@code false}.
*
Nashorn, by setting
the {@link #setSharedEngine sharedEngine} property to {@code false}.
*
*
* @author Sebastien Deleuze
* @author Sebastien Deleuze
* @since 4.2
* @since 4.2
...
@@ -102,8 +100,10 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
...
@@ -102,8 +100,10 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
/**
/**
* When set to {@code false}, use thread-local {@link ScriptEngine} instances instead
* When set to {@code false}, use thread-local {@link ScriptEngine} instances instead
* of one single shared instance. This flag should be set to {@code false} for those
* of one single shared instance. This flag should be set to {@code false} for those
* using non thread-safe script engines and templating libraries, like Handlebars or
* using non thread-safe script engines with templating libraries not designed for
* React running on Nashorn for example.
* concurrency, like Handlebars or React running on Nashorn for example.
* In this case, Java 8u60 or greater is required due to
* <a href="https://bugs.openjdk.java.net/browse/JDK-8076099">this bug</a>.
* <p>When this flag is set to {@code false}, the script engine must be specified using
* <p>When this flag is set to {@code false}, the script engine must be specified using
* {@link #setEngineName(String)}. Using {@link #setEngine(ScriptEngine)} is not
* {@link #setEngineName(String)}. Using {@link #setEngine(ScriptEngine)} is not
* possible because multiple instances of the script engine need to be created lazily
* possible because multiple instances of the script engine need to be created lazily
...
...
spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc-4.2.xsd
浏览文件 @
8e5244ac
...
@@ -1265,7 +1265,9 @@
...
@@ -1265,7 +1265,9 @@
<xsd:documentation>
<![CDATA[
<xsd:documentation>
<![CDATA[
When set to false, use thread-local ScriptEngine instances instead of one single shared
When set to false, use thread-local ScriptEngine instances instead of one single shared
instance. This flag should be set to false for those using non thread-safe script engines
instance. This flag should be set to false for those using non thread-safe script engines
and templating libraries, like Handlebars or React running on Nashorn for example.
with templating libraries not designed for concurrency, like Handlebars or React
running on Nashorn for example. In this case, Java 8u60 or greater is required due to
this bug: https://bugs.openjdk.java.net/browse/JDK-8076099.
]]>
</xsd:documentation>
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:annotation>
</xsd:attribute>
</xsd:attribute>
...
...
src/asciidoc/web-view.adoc
浏览文件 @
8e5244ac
...
@@ -1489,7 +1489,8 @@ It has been tested with:
...
@@ -1489,7 +1489,8 @@ It has been tested with:
To be able to use script templates integration, you need to have available in your classpath
To be able to use script templates integration, you need to have available in your classpath
the script engine:
the script engine:
* http://openjdk.java.net/projects/nashorn/[Nashorn] Javascript engine is provided builtin with Java 8+
* http://openjdk.java.net/projects/nashorn/[Nashorn] Javascript engine is provided builtin with Java 8+.
Using the latest update release available is highly recommended.
* http://docs.oracle.com/javase/7/docs/technotes/guides/scripting/programmer_guide/#jsengine[Rhino]
* http://docs.oracle.com/javase/7/docs/technotes/guides/scripting/programmer_guide/#jsengine[Rhino]
Javascript engine is provided builtin with Java 6 and Java 7.
Javascript engine is provided builtin with Java 6 and Java 7.
Please notice that using Rhino is not recommended since it does not
Please notice that using Rhino is not recommended since it does not
...
@@ -1617,11 +1618,20 @@ browser facilities not available in the server-side script engine.
...
@@ -1617,11 +1618,20 @@ browser facilities not available in the server-side script engine.
configurer.setEngineName("nashorn");
configurer.setEngineName("nashorn");
configurer.setScripts("polyfill.js", "handlebars.js", "render.js");
configurer.setScripts("polyfill.js", "handlebars.js", "render.js");
configurer.setRenderFunction("render");
configurer.setRenderFunction("render");
configurer.setSharedEngine(false);
return configurer;
return configurer;
}
}
}
}
----
----
[NOTE]
====
Setting the `sharedEngine` property to `false` is required when using non thread-safe
script engines with templating libraries not designed for concurrency, like Handlebars or
React running on Nashorn for example. In that case, Java 8u60 or greater is required due
to https://bugs.openjdk.java.net/browse/JDK-8076099[this bug].
====
`polyfill.js` only defines the `window` object needed by Handlebars to run properly:
`polyfill.js` only defines the `window` object needed by Handlebars to run properly:
[source,javascript,indent=0]
[source,javascript,indent=0]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录