spring 3.1.0.M 注解MVC + filter + AOP + memcache + C3P0

本文详细介绍了如何将Spring 3.1的注解MVC与Filter、AOP、Memcached缓存和C3P0数据源进行整合。通过配置Web.xml和Spring的demo.xml,实现了数据源、过滤器、AOP切面和缓存管理。同时,展示了如何在Controller和Filter中使用这些组件,并在DAO层使用JDBC进行数据操作。

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

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">  
  3.   <display-name>springDemo</display-name>  
  4.   <welcome-file-list>  
  5.     <welcome-file>index.do</welcome-file>  
  6.   </welcome-file-list>  
  7.   <listener>  
  8.     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
  9.   </listener>  
  10.   <context-param>  
  11.     <param-name>contextConfigLocation</param-name>  
  12.     <param-value>/WEB-INF/demo.xml</param-value>  
  13.   </context-param>  
  14.   <servlet>  
  15.     <servlet-name>springContent</servlet-name>  
  16.     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
  17.     <init-param>  
  18.       <param-name>contextConfigLocation</param-name>  
  19.       <param-value>/WEB-INF/demo.xml</param-value>  
  20.     </init-param>  
  21.   </servlet>  
  22.   <servlet-mapping>  
  23.     <servlet-name>springContent</servlet-name>  
  24.     <url-pattern>*.do</url-pattern>  
  25.   </servlet-mapping>  
  26.   <filter>  
  27.     <filter-name>DelegatingFilterProxy</filter-name>  
  28.     <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>  
  29.     <init-param>  
  30.       <param-name>targetBeanName</param-name>  
  31.       <param-value>filter_saveuserinfo</param-value>  
  32.     </init-param>  
  33.     <init-param>  
  34.       <param-name>targetFilterLifecycle</param-name>  
  35.       <param-value>true</param-value>  
  36.     </init-param>  
  37.   </filter>  
  38.   <filter-mapping>  
  39.     <filter-name>DelegatingFilterProxy</filter-name>  
  40.     <url-pattern>*.do</url-pattern>  
  41.   </filter-mapping>  
  42. </web-app>  
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <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

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  3.     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:cache="http://www.springframework.org/schema/cache"  
  4.     xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc"  
  5.     xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jms="http://www.springframework.org/schema/jms"  
  6.     xmlns:lang="http://www.springframework.org/schema/lang" xmlns:mvc="http://www.springframework.org/schema/mvc"  
  7.     xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:p="http://www.springframework.org/schema/p"  
  8.     xmlns:task="http://www.springframework.org/schema/task" xmlns:tx="http://www.springframework.org/schema/tx"  
  9.     xmlns:util="http://www.springframework.org/schema/util"  
  10.     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd  
  11.         http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd  
  12.         http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd  
  13.         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd  
  14.         http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd  
  15.         http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd  
  16.         http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.1.xsd  
  17.         http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.1.xsd  
  18.         http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd  
  19.         http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd  
  20.         http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd  
  21.         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  
  22.         http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">  
  23.   
  24.     <context:annotation-config />  
  25.     <context:component-scan base-package="com.netel" />  
  26.     <aop:aspectj-autoproxy />  
  27.       
  28.       
  29.     <!-- C3P0连接池配置 -->  
  30.     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"  
  31.         destroy-method="close">  
  32.         <property name="driverClass" value="com.mysql.jdbc.Driver" />  
  33.         <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/keyword_list" />  
  34.         <property name="user" value="root" />  
  35.         <property name="password" value="123456" />  
  36.     </bean>  
  37.       
  38.     <bean id="jdbc" class="org.springframework.jdbc.core.JdbcTemplate">  
  39.         <property name="dataSource" ref="dataSource" />  
  40.     </bean>  
  41.   
  42.     <!-- memcache缓存池 -->  
  43.     <bean id="memcachedPool" class="com.danga.MemCached.SockIOPool"  
  44.         factory-method="getInstance" init-method="initialize" destroy-method="shutDown">  
  45.         <constructor-arg>  
  46.             <value>neeaMemcachedPool</value>  
  47.         </constructor-arg>  
  48.         <property name="servers">  
  49.             <list>  
  50.                 <value>127.0.0.1:12111</value>  
  51.             </list>  
  52.         </property>  
  53.         <property name="initConn">  
  54.             <value>20</value>  
  55.         </property>  
  56.         <property name="minConn">  
  57.             <value>10</value>  
  58.         </property>  
  59.         <property name="maxConn">  
  60.             <value>50</value>  
  61.         </property>  
  62.         <property name="maintSleep">  
  63.             <value>30000</value>  
  64.         </property>  
  65.         <property name="nagle">  
  66.             <value>false</value>  
  67.         </property>  
  68.         <property name="socketTO">  
  69.             <value>3000</value>  
  70.         </property>  
  71.     </bean>  
  72.   
  73.     <!-- 缓存客服端 -->  
  74.     <bean id="memcachedClient" class="com.danga.MemCached.MemCachedClient">  
  75.         <constructor-arg>  
  76.             <value>neeaMemcachedPool</value>  
  77.         </constructor-arg>  
  78.     </bean>  
  79.           
  80. </beans>  
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:cache="http://www.springframework.org/schema/cache"
	xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
	xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jms="http://www.springframework.org/schema/jms"
	xmlns:lang="http://www.springframework.org/schema/lang" xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:task="http://www.springframework.org/schema/task" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="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">

	<context:annotation-config />
	<context:component-scan base-package="com.netel" />
	<aop:aspectj-autoproxy />
	
	
	<!-- C3P0连接池配置 -->
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
		destroy-method="close">
		<property name="driverClass" value="com.mysql.jdbc.Driver" />
		<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/keyword_list" />
		<property name="user" value="root" />
		<property name="password" value="123456" />
	</bean>
	
	<bean id="jdbc" class="org.springframework.jdbc.core.JdbcTemplate">
		<property name="dataSource" ref="dataSource" />
	</bean>

	<!-- memcache缓存池 -->
	<bean id="memcachedPool" class="com.danga.MemCached.SockIOPool"
		factory-method="getInstance" init-method="initialize" destroy-method="shutDown">
		<constructor-arg>
			<value>neeaMemcachedPool</value>
		</constructor-arg>
		<property name="servers">
			<list>
				<value>127.0.0.1:12111</value>
			</list>
		</property>
		<property name="initConn">
			<value>20</value>
		</property>
		<property name="minConn">
			<value>10</value>
		</property>
		<property name="maxConn">
			<value>50</value>
		</property>
		<property name="maintSleep">
			<value>30000</value>
		</property>
		<property name="nagle">
			<value>false</value>
		</property>
		<property name="socketTO">
			<value>3000</value>
		</property>
	</bean>

	<!-- 缓存客服端 -->
	<bean id="memcachedClient" class="com.danga.MemCached.MemCachedClient">
		<constructor-arg>
			<value>neeaMemcachedPool</value>
		</constructor-arg>
	</bean>
		
</beans>

controller

  1. package com.netel.web;  
  2.   
  3. import javax.annotation.Resource;  
  4. import javax.servlet.http.HttpServletRequest;  
  5. import javax.servlet.http.HttpServletResponse;  
  6.   
  7. import org.springframework.stereotype.Controller;  
  8. import org.springframework.web.bind.annotation.RequestMapping;  
  9. import org.springframework.web.servlet.ModelAndView;  
  10.   
  11. import com.danga.MemCached.MemCachedClient;  
  12. import com.netel.dao.GetKeyword;  
  13.   
  14. @Controller  
  15. public class Controller_index {  
  16.       
  17.     @Resource(name="memcachedClient")  
  18.     private MemCachedClient client;  
  19.       
  20.     @Resource(name="keyword_dao")  
  21.     private GetKeyword dao;  
  22.       
  23.     public void setClient(MemCachedClient client) {  
  24.         this.client = client;  
  25.     }  
  26.   
  27.     public void setDao(GetKeyword dao) {  
  28.         this.dao = dao;  
  29.     }  
  30.   
  31.   
  32.     @RequestMapping("/index.do")  
  33.     public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {  
  34.         ModelAndView v = new ModelAndView("index.jsp");  
  35.         System.out.println("进入controller");  
  36.         String tmp1 = "controller    " + client;  
  37.         String tmp2 = "controller    " + dao.getAllData();  
  38.         String tmp3 = "controller    " +request.getParameter("name");  
  39.           
  40.         System.out.println(tmp1);  
  41.         System.out.println(tmp2);  
  42.         System.out.println(tmp3);  
  43.           
  44.         v.addObject("tmp1", tmp1);  
  45.         v.addObject("tmp2", tmp2);  
  46.         v.addObject("tmp3", tmp3);  
  47.         return v;  
  48.     }  
  49. }  

filter

  1. package com.netel.web;  
  2.   
  3. import java.io.IOException;  
  4.   
  5. import javax.annotation.Resource;  
  6. import javax.servlet.Filter;  
  7. import javax.servlet.FilterChain;  
  8. import javax.servlet.FilterConfig;  
  9. import javax.servlet.ServletException;  
  10. import javax.servlet.ServletRequest;  
  11. import javax.servlet.ServletResponse;  
  12.   
  13. import org.springframework.stereotype.Component;  
  14.   
  15. import com.danga.MemCached.MemCachedClient;  
  16. import com.netel.dao.GetKeyword;  
  17.   
  18.   
  19. @Component("filter_saveuserinfo")  
  20. public class Filter_saveUserInfo implements Filter {  
  21.       
  22.     @Resource(name="memcachedClient")  
  23.     private MemCachedClient client;  
  24.       
  25.     @Resource(name="keyword_dao")  
  26.     private GetKeyword dao;  
  27.       
  28.     public void setClient(MemCachedClient client) {  
  29.         this.client = client;  
  30.     }  
  31.   
  32.     public void setDao(GetKeyword dao) {  
  33.         this.dao = dao;  
  34.     }  
  35.       
  36.       
  37.     /**  
  38.      * Default constructor.   
  39.      */  
  40.     public Filter_saveUserInfo() {  
  41.     }  
  42.   
  43.     /**  
  44.      * @see Filter#destroy()  
  45.      */  
  46.     public void destroy() {  
  47.     }  
  48.   
  49.     /**  
  50.      * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)  
  51.      */  
  52.     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {  
  53.         System.out.println("进入filter\t"+ client + "\t" + dao);        
  54.                 chain.doFilter(request, response);  
  55.     }  
  56.   
  57.     /**  
  58.      * @see Filter#init(FilterConfig)  
  59.      */  
  60.     public void init(FilterConfig fConfig) throws ServletException {  
  61.     }  
  62.   
  63. }  

dao  随便写了查询方法

  1. package com.netel.dao;  
  2.   
  3. import java.sql.ResultSet;  
  4. import java.sql.SQLException;  
  5. import java.util.HashMap;  
  6.   
  7. import javax.annotation.Resource;  
  8.   
  9. import org.springframework.dao.DataAccessException;  
  10. import org.springframework.jdbc.core.JdbcTemplate;  
  11. import org.springframework.jdbc.core.ResultSetExtractor;  
  12. import org.springframework.stereotype.Repository;  
  13.   
  14. @Repository("keyword_dao")  
  15. public class GetKeyword_imple implements GetKeyword {  
  16.       
  17.     @Resource(name="jdbc")  
  18.     private JdbcTemplate jdbc;  
  19.   
  20.     public void setJdbc(JdbcTemplate jdbc) {  
  21.         this.jdbc = jdbc;  
  22.     }  
  23.   
  24.   
  25.     @Override  
  26.     public HashMap<String, String> getAllData() {  
  27.         String sql = "SELECT keyword, count( keyword ) as qty FROM keyword_list GROUP BY keyword ORDER BY qty DESC";  
  28.         return (HashMap<String, String>) jdbc.query(sql, new ResultSetExtractor<HashMap<String, String>>(){  
  29.   
  30.             @Override  
  31.             public HashMap<String, String> extractData(ResultSet rs)  
  32.                     throws SQLException, DataAccessException {  
  33.                   
  34.                 HashMap<String, String> map = new HashMap<String, String>();  
  35.                 while (rs.next()) {  
  36.                     map.put(rs.getString("keyword"),  rs.getString("qty"));  
  37.                 }  
  38.                 return map;  
  39.             }  
  40.         });  
  41.     }  
  42.   
  43. }  

AOP

  1. package com.netel.service;  
  2.   
  3. import javax.annotation.Resource;  
  4.   
  5. import org.aspectj.lang.ProceedingJoinPoint;  
  6. import org.aspectj.lang.annotation.After;  
  7. import org.aspectj.lang.annotation.AfterThrowing;  
  8. import org.aspectj.lang.annotation.Around;  
  9. import org.aspectj.lang.annotation.Aspect;  
  10. import org.aspectj.lang.annotation.Before;  
  11. import org.springframework.stereotype.Component;  
  12.   
  13. import com.danga.MemCached.MemCachedClient;  
  14. import com.netel.dao.GetKeyword;  
  15.   
  16. @Aspect  
  17. @Component  
  18. public class AOP_loginfo {  
  19.       
  20.     @Resource(name="memcachedClient")  
  21.     private MemCachedClient client;  
  22.       
  23.     @Resource(name="keyword_dao")  
  24.     private GetKeyword dao;  
  25.       
  26.     public void setClient(MemCachedClient client) {  
  27.         this.client = client;  
  28.     }  
  29.   
  30.     public void setDao(GetKeyword dao) {  
  31.         this.dao = dao;  
  32.     }  
  33.   
  34.     /**  
  35.      * 所有带RequestMapping注解的方法  
  36.      */  
  37.     private final static String el = "@annotation(org.springframework.web.bind.annotation.RequestMapping)";  
  38.   
  39.     @Before(el)  
  40.     public void before() {  
  41.         System.out.println("before\t" + client + "\t" + dao);  
  42.     }  
  43.   
  44.     @After(el)  
  45.     public void after() {  
  46.         System.out.println("after\t" + client + "\t" + dao);  
  47.     }  
  48.   
  49.     @Around(el)  
  50.     public Object around(ProceedingJoinPoint p) {  
  51.         for (Object obj : p.getArgs()) {  
  52.             System.out.println("参数:" + obj);  
  53.         }  
  54.         Object ob = null;  
  55.   
  56.         try {  
  57.             System.out.println("around前\t" + client + "\t" + dao);  
  58.             ob = p.proceed();  
  59.             System.out.println("around后\t" + client + "\t" + dao);  
  60.         } catch (Throwable e) {  
  61.             e.printStackTrace();  
  62.         }  
  63.   
  64.         return ob;  
  65.     }  
  66.       
  67.     @AfterThrowing(value = elthrowing="e")  
  68.     public void throwing(Exception e){  
  69.         System.out.println("出异常了"  + client + "\t" + dao + e);  
  70.     }  
  71.   
  72. }  

 

index.jsp

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"  
  2.     pageEncoding="UTF-8" isELIgnored="false"%>  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
  4. <html>  
  5. <head>  
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
  7. <title>Insert title here</title>  
  8. </head>  
  9. <body>  
  10.     wca..........<br>  
  11.     ${tmp1 }<br>  
  12.     ${tmp2 }<br>  
  13.     ${tmp3 }<br>  
  14.       
  15.     <%=request.getAttribute("tmp1") %> <br>  
  16.     <%=request.getAttribute("tmp2") %> <br>  
  17.     <%=request.getAttribute("tmp3") %> <br>  
  18. </body>  
  19. </html>  
发布。运行。控制台输出

 

 

  1. 进入filter    com.danga.MemCached.MemCachedClient@e6529c  com.netel.dao.GetKeyword_imple@1399ae5  
  2. before  com.danga.MemCached.MemCachedClient@e5f1d   com.netel.dao.GetKeyword_imple@1869929  
  3. 参数:org.apache.catalina.connector.RequestFacade@1b15387  
  4. 参数:org.apache.catalina.connector.ResponseFacade@e2da7a  
  5. around前 com.danga.MemCached.MemCachedClient@e5f1d   com.netel.dao.GetKeyword_imple@1869929  
  6. 进入controller  
  7. controller    com.danga.MemCached.MemCachedClient@e5f1d  
  8. controller    {3=62=4AA=11=11111=14=1, ä¸­=3}  
  9. controller    null  
  10. after   com.danga.MemCached.MemCachedClient@e5f1d   com.netel.dao.GetKeyword_imple@1869929  
  11. around后 com.danga.MemCached.MemCachedClient@e5f1d   com.netel.dao.GetKeyword_imple@1869929  

 

index.jsp页面输出

  1. wca..........  
  2. controller com.danga.MemCached.MemCachedClient@e5f1d  
  3. controller {3=62=4AA=11=11111=14=1, ä¸­=3}  
  4. controller null  
  5. controller com.danga.MemCached.MemCachedClient@e5f1d  
  6. controller {3=62=4AA=11=11111=14=1, ä¸­=3}  
  7. controller null  

 

改变URL地址

  1. http://localhost:8080/AnnotationDemo/index.do?name=aaa  
JSP页面

  1. wca..........  
  2. controller com.danga.MemCached.MemCachedClient@e5f1d  
  3. controller {3=62=4AA=11=11111=14=1, ä¸­=3}  
  4. controller aaa  
  5. controller com.danga.MemCached.MemCachedClient@e5f1d  
  6. controller {3=62=4AA=11=11111=14=1, ä¸­=3}  
  7. controller aaa  
完成。。
打开链接下载源码: https://pan.quark.cn/s/bb4802fc03a0 在 VSCode 环境中构建开发平台及项目启动是至关重要的环节,对于开发者而言,熟练掌握这一环节能够显著提升开发工作的效率与成果。接下来,我们将详尽阐述如何构建 VSCode 开发环境并启动相关项目。 一、安装 Node.js 在着手构建 VSCode 开发环境之前,首要任务是安装 Node.js。Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行时平台,主要应用于服务器端应用程序的开发。获取 Node.js 可以通过访问其官方网站下载安装包,并依照指示逐步完成安装流程。安装结束后,可在开始菜单中键入 cmd,随后输入 node -v 和 npm -v 以验证安装是否成功。 二、安装 Vue 引入 Vue 的目的是为了运用 Vue.js 框架进行 web 应用程序的开发。Vue.js 是一种渐进式的 JavaScript 框架,专门用于构建 web 应用程序。安装 Vue 可以借助 npm 或 cnpm 等工具实现。关键在于安装 Vue 的命令行界面(CLI)工具,并使用 Vue init 命令来创建全新的 Vue 项目。 三、设置环境变量 设置环境变量的目的是确保 Node.js 和 npm 工具能够正常运行。需要调整 PATH 变量,将 Node.js 的安装路径加入到 PATH 变量中。此外,还需安装 cnpm 工具,以提升 npm 的安装效率。同时,也要安装 Vue 的 CLI 工具,并对其进行环境变量的配置。 四、构建项目 构建项目涉及使用 Vue init 命令来创建新的 Vue 项目。需要打开 Terminal 菜单,选择 new...
内容概要:本文详细介绍了一种基于贝叶斯网络的短期电能负荷预测方法,特别关注电力系统中不确定性因素(如风电出力波动、负荷随机变化等)对预测精度的影响。通过构建贝叶斯网络模型,有效捕捉输入变量之间的概率依赖关系与联合分布特性,实现了在复杂不确定环境下更高精度的负荷预测。该方法结合Python编程语言完成算法实现,提供了完整的代码支持,便于复现与扩展。相较于传统点预测模型,该方法能够输出负荷的概率分布与置信区间,增强了预测结果的风险评估能力,适用于现代含高比例可再生能源的电力系统运行决策。; 适合人群:具备一定电力系统基础知识、概率统计理论背景以及Python编程能力的科研人员、高校研究生、能源领域工程师及从事智能电网、能源预测等相关工作的技术人员。; 使用场景及目标:①应用于短期电能负荷预测任务,尤其适用于风电、光伏等新能源接入场景下量化源-荷双重不确定性影响;②为微电网调度、电力市场出清、需求响应策略制定及电网安全稳定分析提供具备风险评估能力的负荷输入数据;③帮助研究人员深入理解贝叶斯网络在能源时序预测中的建模流程,包括结构学习、参数估计与概率推理等关键技术环节。; 阅读建议:建议读者结合文中提供的Python代码进行动手实践,重点理解贝叶斯网络的构建过程与不确定性传播机制,可通过引入实际历史负荷与气象数据进行模型训练与验证,并与其他主流预测模型(如LSTM、GRU、XGBoost等)开展对比实验,以全面评估其在不同场景下的鲁棒性与优越性。
源码直接下载地址: https://pan.quark.cn/s/a4b39357ea24 台达VFD037E43A变频器使用说明书包含了产品的基础安装、操作及维护等方面的全面信息,以下为其知识要点具体阐述: 1. 安全操作注意事项:在操作台达VFD037E43A变频器之前,说明书着重指出必须研读安全信息以保障操作人员与设备的双重安全。使用前应核实电源已切断,防止触碰带电线路,同时对内部电路板的静电防护措施也做了规定。此外,说明书还明确禁止非专业人员擅自改装变频器。 2. 接地规范:说明书说明了230V和460V系列变频器分别遵循第三类接地和特殊接地标准,从而确保了安全接地的合规性。 3. 安装与连接:说明书详尽说明了产品装置、搬运、接线方法、主回路端子及控制回路端子等环节,为用户正确配置和连接变频器提供了指导。 4. 零件选择:说明书内含零件选购参考,协助用户依据实际需求挑选适配的零件。 5. 参数调节:说明书中的“参数索引”及“参数深入解释”部分指导用户如何设定和调整变频器的运行参数。 6. 应用案例:在“成功实施案例”部分,说明书以实例形式向用户展示变频器在不同工作场景下的应用技巧。 7. 问题诊断:说明书提供了“警示代码解析”和“错误代码解析”,帮助用户识别变频器的常见故障并进行排除。 8. 通讯方式:说明书介绍了“CANopen通讯基础”和“BACnet应用指南及流程”,使用户能够掌握如何通过这些通讯方式将变频器融入工业自动化系统。 9. 特殊功能介绍:说明书还收录了“可编程逻辑控制器应用”和“PT100操作指南”,阐述了变频器的可编程逻辑控制器特性及温度传感器操作方法。 10. 网站与升级:说明书指出产品资料如有变动可通过台达电子工业自动化类产品的官方网...
代码转载自:https://pan.quark.cn/s/a4b39357ea24 DevExpress VCL v21.1.7 for Delphi 11 Alexandria是一个为Embarcadero Delphi 11 Alexandria量身定制的高级组件库,其核心目标是增强Delphi开发者的工作效率并提升应用程序的整体品质。该套件包含了大量的用户界面元素、数据可视化工具以及业务组件,能够全面满足从桌面软件到Web和移动应用的开发需求。 DevExpress VCL是基于Visual Component Library(VCL)架构的,而VCL是Delphi开发Windows应用的关键技术。VCL提供了许多标准化的组件,例如按钮、表格、菜单等,使得开发者能够迅速构建出具备专业外观和功能的应用程序。在此基础上,DevExpress的VCL扩展了该框架,引入了更多高级特性和功能,具体包括: 1. **用户界面元素**:涵盖了现代且适应性强的高级网格控件,如GridControl和TreeListControl,这些控件具备复杂的数据绑定、排序、过滤和分组能力。此外,还有RichEdit、BarManager、Ribbon、DockingPanels等工具,可用于设计复杂的界面布局和导航系统。 2. **数据绑定和编辑功能**:DevExpress提供了一系列高度可定制的编辑工具,例如DateEdit、TimeEdit、MaskEdit等,这些工具能够与多种数据库实现无缝的数据连接,确保数据输入的精确性和统一性。 3. **图表和报表工具**:涵盖了多种图表类型,如柱状图、饼图、线图,以及先进的数据可视化解决方案,用于生成交互式的报表和仪表板。这些组...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值