First, let's review the principles and processes of Web containers calling servlet, and then explain the principles of filter interception, filter class and fiterchain class. Register and run the filter. Write a practical case: Use filter to implement centralized resource access protection.
I analyzed the dohead and doget calling principles of httpservlet again, and explained the Packaging Principles of request and response objects: the relationship between writer and outputstream: Leave the trouble to myself and leave convenience to others! The false writer in the false httpservletresponse is the packaging of the false outputstream.
Let filter1 intercept the default servletobject, And let filter2intercept the .html urlobject. Which filter is used to intercept the.html file?
This afternoon, I will explain how to manage Message Resources in spring and how to integrate Spring into web development.
<% @ 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 =
// 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>
<%
Enumeration E = application. getattributenames ();
While (E. hasmoreelements ())
{
String attributename = (string) E. nextelement ();
Out. println (attributename + "<br> ");
}
%>
-------------------------
Note: If the resource file is stored in a subdirectory, replace "." with "/".
<Beans>
<Bean id = "messagesource" class = "org. springframework. Context. Support. resourcebundlemessagesource">
<Property name = "basename">
<Value> resource. Messages </value>
</Property>
</Bean>
</Beans>
-----------------------------
Tip: do not configure the contextconfiglocation parameter. In this way, the applicationcontext. xml file will be searched. In fact, dispatchservlet also has a parameter named contextconfiglocation. If this parameter is not set, Servlet uses the <servlet-Name>-servlet. xml file by default to create its applicationcontext object.
<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 -->