Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
b5708590
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,发现更多精彩内容 >>
提交
b5708590
编写于
6月 16, 2009
作者:
A
Arjen Poutsma
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Moved REST views to View chapter.
上级
7b1ff585
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
669 addition
and
626 deletion
+669
-626
spring-framework-reference/src/rest.xml
spring-framework-reference/src/rest.xml
+0
-114
spring-framework-reference/src/view.xml
spring-framework-reference/src/view.xml
+669
-512
未找到文件。
spring-framework-reference/src/rest.xml
浏览文件 @
b5708590
...
...
@@ -38,120 +38,6 @@
configuration
</link>
to understand the general programming model.
</para>
</section>
<section
id=
"rest-views"
>
<title>
Views
</title>
<para>
Several views were added in Spring 3 to help support creating
RESTful services. They are:
</para>
<itemizedlist>
<listitem>
<para><classname>
AbstractAtomFeedView
</classname>
- returns an Atom
feed
</para>
</listitem>
<listitem>
<para><classname>
AbstractRssFeedView
</classname>
- returns a RSS
feed
</para>
</listitem>
<listitem>
<para><classname>
MarshallingView
</classname>
- returns an XML
representation using Spring's Object to XML mapping (OXM)
functionality
</para>
</listitem>
</itemizedlist>
<note>
<para>
Available separately is the
<classname>
JacksonJsonView
</classname>
included as part of the Spring
JavaScript project.
</para>
</note>
<section
id=
"rest-feedview"
>
<title>
Feed Views
</title>
<para>
Both
<classname>
AbstractAtomFeedView
</classname>
and
<classname>
AbstractRssFeedView
</classname>
inherit from the base class
<classname>
AbstractFeedView
</classname>
and are used to provide Atom
and RSS Feed views respectfully. They are based on java.net's
<ulink
url=
"https://rome.dev.java.net"
>
ROME
</ulink>
project and are located
in the package
<literal>
org.springframework.web.servlet.view.feed
</literal>
.
</para>
<para><classname>
AbstractAtomFeedView
</classname>
requires you to
implement the
<methodname>
buildFeedEntries
</methodname>
method and
optionally override the
<methodname>
buildFeedMetadata
</methodname>
method (the default implementation is empty), as shown below
</para>
<programlisting
language=
"java"
>
public class SampleContentAtomView extends AbstractAtomFeedView {
@Override
protected void buildFeedMetadata(Map
<
String, Object
>
model, Feed feed,
HttpServletRequest request) {
// implementation omitted
}
@Override
protected List
<
Entry
>
buildFeedEntries(Map
<
String, Object
>
model,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
// implementation omitted
}
}
</programlisting>
<para>
Similar requirements apply for implementing
<classname>
AbstractRssFeedView
</classname>
, as shown below
</para>
<programlisting
language=
"java"
>
public class SampleContentAtomView extends AbstractRssFeedView {
@Override
protected void buildFeedMetadata(Map
<
String, Object
>
model, Channel feed,
HttpServletRequest request) {
// implementation omitted
}
@Override
protected List
<
Item
>
buildFeedItems(Map
<
String, Object
>
model,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
// implementation omitted
}
}
</programlisting>
<para>
The
<methodname>
buildFeedItems
</methodname>
and
<methodname>
buildFeedEntires
</methodname>
pass in the HTTP request in
case you need to access the Locale. The HTTP response is passed in
only for the setting of cookies or other HTTP headers. The feed will
automatically be written to the response object after the method
returns.
</para>
<para>
For an example of creating a Atom view please refer to Alef
Arendsen's SpringSource TeamBlog
<ulink
url=
"http://blog.springsource.com/2009/03/16/adding-an-atom-view-to-an-application-using-springs-rest-support/"
>
entry
</ulink>
.
</para>
</section>
<section>
<title>
XML Marshalling View
</title>
<para>
The
<classname>
MarhsallingView
</classname>
uses a XML
<interfacename>
Marshaller
</interfacename>
defined in the
<classname>
org.springframework.oxm
</classname>
package to render the
response content as XML. The object to be marshalled can be set
explicitly using
<classname>
MarhsallingView
</classname>
's
<property>
modelKey
</property>
bean property. Alternatively, the view
will iterate over all model properties marhsall only those types that
are supported by the
<interfacename>
Marshaller
</interfacename>
. For
more information on the functionality in the
<classname>
org.springframework.oxm
</classname>
package refer to the
chapter
<link
linkend=
"oxm"
>
Marshalling XML using O/X
Mappers
</link>
.
</para>
</section>
</section>
<section
id=
"rest-method-conversion"
>
<title>
HTTP Method Conversion
</title>
...
...
spring-framework-reference/src/view.xml
浏览文件 @
b5708590
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录