上一篇 | 下一篇

框架构建 Portlet 应用

发布: 2008-7-01 22:14 | 作者: admin | 来源: | 查看: 4次

整个应用的Web图如下:

图4

实现表现层对Service层的访问

1. 配置web.xml文件

为了实现表现层对Service层的调用,我们首先需要更改web.xml文件,在里面添加如下代码:

代码清单9:

contextConfigLocation

/WEB-INF/classes/applicationContext-hibernate.xml

SpringContextServlet

org.springframework.web.context.ContextLoaderServlet

1

SpringContextServlet

/*

通过这样的配置,示例应用程序在启动的时候,会首先初始化Spring框架自带的ContextLoaderServlet,这个Servlet的作用就是读取由contextConfigLocation指定的Spring配置文件的位置,初始化Spring框架的Context对象,并将这个对象保存在ServletContext中,留待Action调用。

同时,为了解决中文输入问题,我们在web.xml中加入过滤器,过滤器的具体代码请见附件。

代码清单10:

SetCharacterEncodingFilter

SetCharacterEncodingFilter

com.ibm.sample.web.filter.SetCharacterEncodingFilter

encoding

GB2312

ignore

true

SetCharacterEncodingFilter

/SetCharacterEncodingFilter

SetCharacterEncodingFilter

action

[8] [9]

字号: | 推荐给好友

评分:0

我来说两句