您的位置:首页 > 运维架构 > Linux

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-->
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: