设为首页 收藏本站
查看: 1034|回复: 0

[经验分享] spring 3.1.0.M 注解MVC + filter + AOP + memcache + C3P0

[复制链接]

尚未签到

发表于 2015-11-18 11:44:08 | 显示全部楼层 |阅读模式
  spring 3.1的包全导了 + 依赖包 commons-logging-1.1.1.jar  +  servlet-api.jar


  AOP需要的几个包 aopalliance.jar  +  aspectjrt.jar  +  aspectjweaver.jar  +  cglib-nodep-2.1_3.jar
  memcache 需要的包   java_memcached-release_2.6.1.jar   +依赖包   slf4j-api-1.6.1.jar  +  slf4j-simple-1.6.1.jar   +   commons-pool-1.5.6.jar


  C3P0 需要的包 c3p0-0.9.1.2.jar   数据库包  mysql-connector-java-5.1.12-bin.jar
  


  WEB.xml
  

[html]
view plaincopyprint?

  • <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>  
  • <web-app xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:web=&quot;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd&quot; id=&quot;WebApp_ID&quot; version=&quot;3.0&quot;>  
  •   <display-name>springDemo</display-name>  
  •   <welcome-file-list>  
  •     <welcome-file>index.do</welcome-file>  
  •   </welcome-file-list>  
  •   <listener>  
  •     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
  •   </listener>  
  •   <context-param>  
  •     <param-name>contextConfigLocation</param-name>  
  •     <param-value>/WEB-INF/demo.xml</param-value>  
  •   </context-param>  
  •   <servlet>  
  •     <servlet-name>springContent</servlet-name>  
  •     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
  •     <init-param>  
  •       <param-name>contextConfigLocation</param-name>  
  •       <param-value>/WEB-INF/demo.xml</param-value>  
  •     </init-param>  
  •   </servlet>  
  •   <servlet-mapping>  
  •     <servlet-name>springContent</servlet-name>  
  •     <url-pattern>*.do</url-pattern>  
  •   </servlet-mapping>  
  •   <filter>  
  •     <filter-name>DelegatingFilterProxy</filter-name>  
  •     <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>  
  •     <init-param>  
  •       <param-name>targetBeanName</param-name>  
  •       <param-value>filter_saveuserinfo</param-value>  
  •     </init-param>  
  •     <init-param>  
  •       <param-name>targetFilterLifecycle</param-name>  
  •       <param-value>true</param-value>  
  •     </init-param>  
  •   </filter>  
  •   <filter-mapping>  
  •     <filter-name>DelegatingFilterProxy</filter-name>  
  •     <url-pattern>*.do</url-pattern>  
  •   </filter-mapping>  
  • </web-app>  

<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<web-app xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:web=&quot;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd&quot; id=&quot;WebApp_ID&quot; version=&quot;3.0&quot;>
<display-name>springDemo</display-name>
<welcome-file-list>
<welcome-file>index.do</welcome-file>
</welcome-file-list>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/demo.xml</param-value>
</context-param>
<servlet>
<servlet-name>springContent</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/demo.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springContent</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<filter>
<filter-name>DelegatingFilterProxy</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetBeanName</param-name>
<param-value>filter_saveuserinfo</param-value>
</init-param>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>DelegatingFilterProxy</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
</web-app>


  
  spring配置文件demo.xml
  

[html]
view plaincopyprint?

  • <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>  
  • <beans xmlns=&quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;  
  •     xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot; xmlns:cache=&quot;http://www.springframework.org/schema/cache&quot;  
  •     xmlns:context=&quot;http://www.springframework.org/schema/context&quot; xmlns:jdbc=&quot;http://www.springframework.org/schema/jdbc&quot;  
  •     xmlns:jee=&quot;http://www.springframework.org/schema/jee&quot; xmlns:jms=&quot;http://www.springframework.org/schema/jms&quot;  
  •     xmlns:lang=&quot;http://www.springframework.org/schema/lang&quot; xmlns:mvc=&quot;http://www.springframework.org/schema/mvc&quot;  
  •     xmlns:oxm=&quot;http://www.springframework.org/schema/oxm&quot; xmlns:p=&quot;http://www.springframework.org/schema/p&quot;  
  •     xmlns:task=&quot;http://www.springframework.org/schema/task&quot; xmlns:tx=&quot;http://www.springframework.org/schema/tx&quot;  
  •     xmlns:util=&quot;http://www.springframework.org/schema/util&quot;  
  •     xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd  
  •         http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd  
  •         http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd  
  •         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd  
  •         http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd  
  •         http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd  
  •         http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.1.xsd  
  •         http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.1.xsd  
  •         http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd  
  •         http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd  
  •         http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd  
  •         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  
  •         http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd&quot;>  
  •   
  •     <context:annotation-config />  
  •     <context:component-scan base-package=&quot;com.netel&quot; />  
  •     <aop:aspectj-autoproxy />  
  •       
  •       
  •     <!-- C3P0连接池配置 -->  
  •     <bean id=&quot;dataSource&quot; class=&quot;com.mchange.v2.c3p0.ComboPooledDataSource&quot;  
  •         destroy-method=&quot;close&quot;>  
  •         <property name=&quot;driverClass&quot; value=&quot;com.mysql.jdbc.Driver&quot; />  
  •         <property name=&quot;jdbcUrl&quot; value=&quot;jdbc:mysql://localhost:3306/keyword_list&quot; />  
  •         <property name=&quot;user&quot; value=&quot;root&quot; />  
  •         <property name=&quot;password&quot; value=&quot;123456&quot; />  
  •     </bean>  
  •       
  •     <bean id=&quot;jdbc&quot; class=&quot;org.springframework.jdbc.core.JdbcTemplate&quot;>  
  •         <property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; />  
  •     </bean>  
  •   
  •     <!-- memcache缓存池 -->  
  •     <bean id=&quot;memcachedPool&quot; class=&quot;com.danga.MemCached.SockIOPool&quot;  
  •         factory-method=&quot;getInstance&quot; init-method=&quot;initialize&quot; destroy-method=&quot;shutDown&quot;>  
  •         <constructor-arg>  
  •             <value>neeaMemcachedPool</value>  
  •         </constructor-arg>  
  •         <property name=&quot;servers&quot;>  
  •             <list>  
  •                 <value>127.0.0.1:12111</value>  
  •             </list>  
  •         </property>  
  •         <property name=&quot;initConn&quot;>  
  •             <value>20</value>  
  •         </property>  
  •         <property name=&quot;minConn&quot;>  
  •             <value>10</value>  
  •         </property>  
  •         <property name=&quot;maxConn&quot;>  
  •             <value>50</value>  
  •         </property>  
  •         <property name=&quot;maintSleep&quot;>  
  •             <value>30000</value>  
  •         </property>  
  •         <property name=&quot;nagle&quot;>  
  •             <value>false</value>  
  •         </property>  
  •         <property name=&quot;socketTO&quot;>  
  •             <value>3000</value>  
  •         </property>  
  •     </bean>  
  •   
  •     <!-- 缓存客服端 -->  
  •     <bean id=&quot;memcachedClient&quot; class=&quot;com.danga.MemCached.MemCachedClient&quot;>  
  •         <constructor-arg>  
  •             <value>neeaMemcachedPool</value>  
  •         </constructor-arg>  
  •     </bean>  
  •          
  • </beans>  

<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<beans xmlns=&quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot; xmlns:cache=&quot;http://www.springframework.org/schema/cache&quot;
xmlns:context=&quot;http://www.springframework.org/schema/context&quot; xmlns:jdbc=&quot;http://www.springframework.org/schema/jdbc&quot;
xmlns:jee=&quot;http://www.springframework.org/schema/jee&quot; xmlns:jms=&quot;http://www.springframework.org/schema/jms&quot;
xmlns:lang=&quot;http://www.springframework.org/schema/lang&quot; xmlns:mvc=&quot;http://www.springframework.org/schema/mvc&quot;
xmlns:oxm=&quot;http://www.springframework.org/schema/oxm&quot; xmlns:p=&quot;http://www.springframework.org/schema/p&quot;
xmlns:task=&quot;http://www.springframework.org/schema/task&quot; xmlns:tx=&quot;http://www.springframework.org/schema/tx&quot;
xmlns:util=&quot;http://www.springframework.org/schema/util&quot;
xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.1.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd&quot;>
<context:annotation-config />
<context:component-scan base-package=&quot;com.netel&quot; />
<aop:aspectj-autoproxy />

<!-- C3P0连接池配置 -->
<bean id=&quot;dataSource&quot; class=&quot;com.mchange.v2.c3p0.ComboPooledDataSource&quot;
destroy-method=&quot;close&quot;>
<property name=&quot;driverClass&quot; value=&quot;com.mysql.jdbc.Driver&quot; />
<property name=&quot;jdbcUrl&quot; value=&quot;jdbc:mysql://localhost:3306/keyword_list&quot; />
<property name=&quot;user&quot; value=&quot;root&quot; />
<property name=&quot;password&quot; value=&quot;123456&quot; />
</bean>
<bean id=&quot;jdbc&quot; class=&quot;org.springframework.jdbc.core.JdbcTemplate&quot;>
<property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; />
</bean>
<!-- memcache缓存池 -->
<bean id=&quot;memcachedPool&quot; class=&quot;com.danga.MemCached.SockIOPool&quot;
factory-method=&quot;getInstance&quot; init-method=&quot;initialize&quot; destroy-method=&quot;shutDown&quot;>
<constructor-arg>
<value>neeaMemcachedPool</value>
</constructor-arg>
<property name=&quot;servers&quot;>
<list>
<value>127.0.0.1:12111</value>
</list>
</property>
<property name=&quot;initConn&quot;>
<value>20</value>
</property>
<property name=&quot;minConn&quot;>
<value>10</value>
</property>
<property name=&quot;maxConn&quot;>
<value>50</value>
</property>
<property name=&quot;maintSleep&quot;>
<value>30000</value>
</property>
<property name=&quot;nagle&quot;>
<value>false</value>
</property>
<property name=&quot;socketTO&quot;>
<value>3000</value>
</property>
</bean>
<!-- 缓存客服端 -->
<bean id=&quot;memcachedClient&quot; class=&quot;com.danga.MemCached.MemCachedClient&quot;>
<constructor-arg>
<value>neeaMemcachedPool</value>
</constructor-arg>
</bean>
</beans>


controller  
  

[html]
view plaincopyprint?

  • package com.netel.web;  
  •   
  • import javax.annotation.Resource;  
  • import javax.servlet.http.HttpServletRequest;  
  • import javax.servlet.http.HttpServletResponse;  
  •   
  • import org.springframework.stereotype.Controller;  
  • import org.springframework.web.bind.annotation.RequestMapping;  
  • import org.springframework.web.servlet.ModelAndView;  
  •   
  • import com.danga.MemCached.MemCachedClient;  
  • import com.netel.dao.GetKeyword;  
  •   
  • @Controller  
  • public class Controller_index {  
  •       
  •     @Resource(name=&quot;memcachedClient&quot;)  
  •     private MemCachedClient client;  
  •       
  •     @Resource(name=&quot;keyword_dao&quot;)  
  •     private GetKeyword dao;  
  •       
  •     public void setClient(MemCachedClient client) {  
  •         this.client = client;  
  •     }  
  •   
  •     public void setDao(GetKeyword dao) {  
  •         this.dao = dao;  
  •     }  
  •   
  •   
  •     @RequestMapping(&quot;/index.do&quot;)  
  •     public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {  
  •         ModelAndView v = new ModelAndView(&quot;index.jsp&quot;);  
  •         System.out.println(&quot;进入controller&quot;);  
  •         String tmp1 = &quot;controller    &quot; &#43; client;  
  •         String tmp2 = &quot;controller    &quot; &#43; dao.getAllData();  
  •         String tmp3 = &quot;controller    &quot; &#43;request.getParameter(&quot;name&quot;);  
  •          
  •         System.out.println(tmp1);  
  •         System.out.println(tmp2);  
  •         System.out.println(tmp3);  
  •          
  •         v.addObject(&quot;tmp1&quot;, tmp1);  
  •         v.addObject(&quot;tmp2&quot;, tmp2);  
  •         v.addObject(&quot;tmp3&quot;, tmp3);  
  •         return v;  
  •     }  
  • }  
  
  filter
  

[html]
view plaincopyprint?

  • package com.netel.web;  
  •   
  • import java.io.IOException;  
  •   
  • import javax.annotation.Resource;  
  • import javax.servlet.Filter;  
  • import javax.servlet.FilterChain;  
  • import javax.servlet.FilterConfig;  
  • import javax.servlet.ServletException;  
  • import javax.servlet.ServletRequest;  
  • import javax.servlet.ServletResponse;  
  •   
  • import org.springframework.stereotype.Component;  
  •   
  • import com.danga.MemCached.MemCachedClient;  
  • import com.netel.dao.GetKeyword;  
  •   
  •   
  • @Component(&quot;filter_saveuserinfo&quot;)  
  • public class Filter_saveUserInfo implements Filter {  
  •       
  •     @Resource(name=&quot;memcachedClient&quot;)  
  •     private MemCachedClient client;  
  •       
  •     @Resource(name=&quot;keyword_dao&quot;)  
  •     private GetKeyword dao;  
  •       
  •     public void setClient(MemCachedClient client) {  
  •         this.client = client;  
  •     }  
  •   
  •     public void setDao(GetKeyword dao) {  
  •         this.dao = dao;  
  •     }  
  •       
  •       
  •     /**  
  •      * Default constructor.   
  •      */  
  •     public Filter_saveUserInfo() {  
  •     }  
  •   
  •     /**  
  •      * @see Filter#destroy()  
  •      */  
  •     public void destroy() {  
  •     }  
  •   
  •     /**  
  •      * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)  
  •      */  
  •     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {  
  •         System.out.println(&quot;进入filter\t&quot;&#43; client &#43; &quot;\t&quot; &#43; dao);        
  •                 chain.doFilter(request, response);  
  •     }  
  •   
  •     /**  
  •      * @see Filter#init(FilterConfig)  
  •      */  
  •     public void init(FilterConfig fConfig) throws ServletException {  
  •     }  
  •   
  • }  
  dao  随便写了查询方法


  
  

[html]
view plaincopyprint?

  • package com.netel.dao;  
  •   
  • import java.sql.ResultSet;  
  • import java.sql.SQLException;  
  • import java.util.HashMap;  
  •   
  • import javax.annotation.Resource;  
  •   
  • import org.springframework.dao.DataAccessException;  
  • import org.springframework.jdbc.core.JdbcTemplate;  
  • import org.springframework.jdbc.core.ResultSetExtractor;  
  • import org.springframework.stereotype.Repository;  
  •   
  • @Repository(&quot;keyword_dao&quot;)  
  • public class GetKeyword_imple implements GetKeyword {  
  •       
  •     @Resource(name=&quot;jdbc&quot;)  
  •     private JdbcTemplate jdbc;  
  •   
  •     public void setJdbc(JdbcTemplate jdbc) {  
  •         this.jdbc = jdbc;  
  •     }  
  •   
  •   
  •     @Override  
  •     public HashMap<String, String> getAllData() {  
  •         String sql = &quot;SELECT keyword, count( keyword ) as qty FROM keyword_list GROUP BY keyword ORDER BY qty DESC&quot;;  
  •         return (HashMap<String, String>) jdbc.query(sql, new ResultSetExtractor<HashMap<String, String>>(){  
  •   
  •             @Override  
  •             public HashMap<String, String> extractData(ResultSet rs)  
  •                     throws SQLException, DataAccessException {  
  •                   
  •                 HashMap<String, String> map = new HashMap<String, String>();  
  •                 while (rs.next()) {  
  •                     map.put(rs.getString(&quot;keyword&quot;),  rs.getString(&quot;qty&quot;));  
  •                 }  
  •                 return map;  
  •             }  
  •         });  
  •     }  
  •   
  • }  
  
  AOP
  

[html]
view plaincopyprint?

  • package com.netel.service;  
  •   
  • import javax.annotation.Resource;  
  •   
  • import org.aspectj.lang.ProceedingJoinPoint;  
  • import org.aspectj.lang.annotation.After;  
  • import org.aspectj.lang.annotation.AfterThrowing;  
  • import org.aspectj.lang.annotation.Around;  
  • import org.aspectj.lang.annotation.Aspect;  
  • import org.aspectj.lang.annotation.Before;  
  • import org.springframework.stereotype.Component;  
  •   
  • import com.danga.MemCached.MemCachedClient;  
  • import com.netel.dao.GetKeyword;  
  •   
  • @Aspect  
  • @Component  
  • public class AOP_loginfo {  
  •       
  •     @Resource(name=&quot;memcachedClient&quot;)  
  •     private MemCachedClient client;  
  •       
  •     @Resource(name=&quot;keyword_dao&quot;)  
  •     private GetKeyword dao;  
  •       
  •     public void setClient(MemCachedClient client) {  
  •         this.client = client;  
  •     }  
  •   
  •     public void setDao(GetKeyword dao) {  
  •         this.dao = dao;  
  •     }  
  •   
  •     /**  
  •      * 所有带RequestMapping注解的方法  
  •      */  
  •     private final static String el = &quot;@annotation(org.springframework.web.bind.annotation.RequestMapping)&quot;;  
  •   
  •     @Before(el)  
  •     public void before() {  
  •         System.out.println(&quot;before\t&quot; &#43; client &#43; &quot;\t&quot; &#43; dao);  
  •     }  
  •   
  •     @After(el)  
  •     public void after() {  
  •         System.out.println(&quot;after\t&quot; &#43; client &#43; &quot;\t&quot; &#43; dao);  
  •     }  
  •   
  •     @Around(el)  
  •     public Object around(ProceedingJoinPoint p) {  
  •         for (Object obj : p.getArgs()) {  
  •             System.out.println(&quot;参数:&quot; &#43; obj);  
  •         }  
  •         Object ob = null;  
  •   
  •         try {  
  •             System.out.println(&quot;around前\t&quot; &#43; client &#43; &quot;\t&quot; &#43; dao);  
  •             ob = p.proceed();  
  •             System.out.println(&quot;around后\t&quot; &#43; client &#43; &quot;\t&quot; &#43; dao);  
  •         } catch (Throwable e) {  
  •             e.printStackTrace();  
  •         }  
  •   
  •         return ob;  
  •     }  
  •       
  •     @AfterThrowing(value = el, throwing=&quot;e&quot;)  
  •     public void throwing(Exception e){  
  •         System.out.println(&quot;出异常了&quot;  &#43; client &#43; &quot;\t&quot; &#43; dao &#43; e);  
  •     }  
  •   
  • }  
  
  index.jsp
  

[html]
view plaincopyprint?

  • <%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot;  
  •     pageEncoding=&quot;UTF-8&quot; isELIgnored=&quot;false&quot;%>  
  • <!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;>  
  • <html>  
  • <head>  
  • <meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;>  
  • <title>Insert title here</title>  
  • </head>  
  • <body>  
  •     wca..........<br>  
  •     ${tmp1 }<br>  
  •     ${tmp2 }<br>  
  •     ${tmp3 }<br>  
  •       
  •     <%=request.getAttribute(&quot;tmp1&quot;) %> <br>  
  •     <%=request.getAttribute(&quot;tmp2&quot;) %> <br>  
  •     <%=request.getAttribute(&quot;tmp3&quot;) %> <br>  
  • </body>  
  • </html>  

发布。运行。控制台输出  
  
  

[html]
view plaincopyprint?

  • 进入filter    com.danga.MemCached.MemCachedClient@e6529c  com.netel.dao.GetKeyword_imple@1399ae5  
  • before  com.danga.MemCached.MemCachedClient@e5f1d   com.netel.dao.GetKeyword_imple@1869929  
  • 参数:org.apache.catalina.connector.RequestFacade@1b15387  
  • 参数:org.apache.catalina.connector.ResponseFacade@e2da7a  
  • around前 com.danga.MemCached.MemCachedClient@e5f1d   com.netel.dao.GetKeyword_imple@1869929  
  • 进入controller  
  • controller    com.danga.MemCached.MemCachedClient@e5f1d  
  • controller    {3=6, 2=4, AA=1, 1=11, 111=1, 4=1, 中=3}  
  • controller    null  
  • after   com.danga.MemCached.MemCachedClient@e5f1d   com.netel.dao.GetKeyword_imple@1869929  
  • around后 com.danga.MemCached.MemCachedClient@e5f1d   com.netel.dao.GetKeyword_imple@1869929  
  
  index.jsp页面输出
  
  

[html]
view plaincopyprint?

  • wca..........  
  • controller com.danga.MemCached.MemCachedClient@e5f1d  
  • controller {3=6, 2=4, AA=1, 1=11, 111=1, 4=1, 中=3}  
  • controller null  
  • controller com.danga.MemCached.MemCachedClient@e5f1d  
  • controller {3=6, 2=4, AA=1, 1=11, 111=1, 4=1, 中=3}  
  • controller null  
  
  改变URL地址


  
  

[html]
view plaincopyprint?

  • http://localhost:8080/AnnotationDemo/index.do?name=aaa  

JSP页面  
  

[html]
view plaincopyprint?

  • wca..........  
  • controller com.danga.MemCached.MemCachedClient@e5f1d  
  • controller {3=6, 2=4, AA=1, 1=11, 111=1, 4=1, 中=3}  
  • controller aaa  
  • controller com.danga.MemCached.MemCachedClient@e5f1d  
  • controller {3=6, 2=4, AA=1, 1=11, 111=1, 4=1, 中=3}  
  • controller aaa  

完成。。
版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-140670-1-1.html 上篇帖子: Memcache 实现tomcat集群session共享 下篇帖子: 如何安装Windows版Memcache
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表