Redhat7 替换Centos7 yum源
2015-11-10 10:31
609 查看
首先回顾Web容器调用Servlet的原理与过程,然后讲解了Filter拦截的原理、Filter类与FiterChain类。Filter的注册与运行。编写一个实用案例:用Filter实现对资源的集中访问保护。
再次分析了HttpServlet的doHead与doGet调用原理,讲解了对请求和响应对象进行包装的原理:writer与OutputStream的关系:把麻烦留给自己,把方便留给别人!假HttpServletResponse中的假Writer又是对假OutputStream的包装
让filter1对default Servlet进行拦截,让filter2对.html url进行拦截,当访问a.html文件时,先是哪个filter进行拦截?
下午为大家讲解了spring中的消息资源管理以及如何在web开发中集成spring。
<%@ page contentType="text/html;charset=GB2312"%>
<%@ taglib prefix="itcast" tagdir="/WEB-INF/tags/test"%>
<%@ page import="org.springframework.context.support.ClassPathXmlApplicationContext"%>
<%@ page import="org.springframework.context.ApplicationContext"%>
<%@ page import="org.springframework.web.context.WebApplicationContext"%>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@ page import="java.util.Enumeration"%>
<itcast:DefineConstants />
${Constants.GREEN}
<%
ApplicationContext applicationContext =
//WebApplicationContextUtils.getWebApplicationContext(application);
(ApplicationContext)application.getAttribute(
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
//= new ClassPathXmlApplicationContext("/resource/applicationContext.xml");
%>
<%= applicationContext.getMessage("hello.title", null,request.getLocale())%>
<%= WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE %>
<br><br>
<%
Enumeration e = application.getAttributeNames();
while(e.hasMoreElements())
{
String attributeName = (String)e.nextElement();
out.println(attributeName + "<br>");
}
%>
-------------------------
重点:如果资源文件存储在某个子目录中,应该用“.”来替代“/”。
<beans>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename">
<value>resource.messages</value>
</property>
</bean>
</beans>
-----------------------------
提示:不配置contextConfigLocation参数也可以,这样,将查找applicationContext.xml文件。其实DispatchServlet也有一个名为contextConfigLocation的参数,如果不设置这个参数,servlet默认使用<servlet-name>-servlet.xml文件来创建其ApplicationContext对象。
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext1.xml</param-value>
</context-param>
---------------------------------
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param-->
再次分析了HttpServlet的doHead与doGet调用原理,讲解了对请求和响应对象进行包装的原理:writer与OutputStream的关系:把麻烦留给自己,把方便留给别人!假HttpServletResponse中的假Writer又是对假OutputStream的包装
让filter1对default Servlet进行拦截,让filter2对.html url进行拦截,当访问a.html文件时,先是哪个filter进行拦截?
下午为大家讲解了spring中的消息资源管理以及如何在web开发中集成spring。
<%@ page contentType="text/html;charset=GB2312"%>
<%@ taglib prefix="itcast" tagdir="/WEB-INF/tags/test"%>
<%@ page import="org.springframework.context.support.ClassPathXmlApplicationContext"%>
<%@ page import="org.springframework.context.ApplicationContext"%>
<%@ page import="org.springframework.web.context.WebApplicationContext"%>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@ page import="java.util.Enumeration"%>
<itcast:DefineConstants />
${Constants.GREEN}
<%
ApplicationContext applicationContext =
//WebApplicationContextUtils.getWebApplicationContext(application);
(ApplicationContext)application.getAttribute(
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
//= new ClassPathXmlApplicationContext("/resource/applicationContext.xml");
%>
<%= applicationContext.getMessage("hello.title", null,request.getLocale())%>
<%= WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE %>
<br><br>
<%
Enumeration e = application.getAttributeNames();
while(e.hasMoreElements())
{
String attributeName = (String)e.nextElement();
out.println(attributeName + "<br>");
}
%>
-------------------------
重点:如果资源文件存储在某个子目录中,应该用“.”来替代“/”。
<beans>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename">
<value>resource.messages</value>
</property>
</bean>
</beans>
-----------------------------
提示:不配置contextConfigLocation参数也可以,这样,将查找applicationContext.xml文件。其实DispatchServlet也有一个名为contextConfigLocation的参数,如果不设置这个参数,servlet默认使用<servlet-name>-servlet.xml文件来创建其ApplicationContext对象。
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext1.xml</param-value>
</context-param>
---------------------------------
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param-->
相关文章推荐
- 中兴MF667S WCDMA猫Linux拨号笔记
- 每天一个linux命令(40):wc命令
- linux下c/c++实例之九识别中文字符
- linux查看和修改系统时间
- linux下MySQL与jdk安装
- Linux下实现MySQL数据备份和恢复的命令使用全攻略
- Kali Linux 常见错误整理
- Centos6.5服务器以Server模式配置H2内存数据库方案
- Linux多线程实践(3) --线程属性
- linux下c/c++实例之八字符串分隔、去空格和转大小写
- 一份简单的在 Linux下编译及调试 C 代码的指南
- Linux多线程实践(4) --线程特定数据
- linux Centos 6.5 安装桌面环境GNOME
- <摘录>CentOS6.5下添加epel源
- linux基础学习笔记
- 如何在Linux下使用Gitblit工具创建Git仓库服务
- 如何在Linux下使用Gitblit工具创建Git仓库服务
- 如何在Linux下使用Gitblit工具创建Git仓库服务
- linux sudo 命令
- linux设置服务开机自启动的三种方式