spring的框架aop应用 在web中必须在web.xml中进行配置好spring,然后在applicationContext.xml中配置上aop事务,这很明显和在junit中不一样。不能直接放入web程序的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我已经全部配置好了<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app> <!-- 启动扫描所有的controller --> <context:component-scan base-package="com.cloud.cn"/> <context:annotation-config/> <!-- 开启aop注解 --> <aop:aspectj-autoproxy/>项目 也启动了,但是就是aop没有织入在applicationContext里面配置<aop:config> <aop:pointcut id="servicePointcut" expression="execution(* com..*.product.action.*.*(..))"/> <!-- 切面 --> <aop:aspect id="myAop" ref="beforeAdvice"> <!-- 执行的切面方法 --> <aop:before method="beforeLogin" pointcut-ref="servicePointcut" /> </aop:aspect> </aop:config>这样程序可以织入before,但是我想用注解,不用shema配置 有人解释下注解模式的aop配置么 问个webservice接口的问题,有人会吗? 一个java输出的问题 jsp中包含一个servlet如何写路径? 请教大侠如何实现2个manytoone方法,应该怎么写? 多个list数据拼凑输出问题 proxool的问题!! JSPSmartUpload的一个 漏洞!大家解决的话,给100分哦1 jdbc驱动问题 rmi问题.希望大吓们都来看看.偶是初学者请指教.谢了. 用过jdom的朋友请进 spring mvc中@RequestMapping(value = "${adminPath}/cms/link")的${adminPath}是什么意思?如何 远程读取Html模板文件出错
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app> <!-- 启动扫描所有的controller -->
<context:component-scan base-package="com.cloud.cn"/>
<context:annotation-config/>
<!-- 开启aop注解 -->
<aop:aspectj-autoproxy/>项目 也启动了,但是就是aop没有织入
在applicationContext里面配置<aop:config>
<aop:pointcut id="servicePointcut" expression="execution(* com..*.product.action.*.*(..))"/>
<!-- 切面 -->
<aop:aspect id="myAop" ref="beforeAdvice">
<!-- 执行的切面方法 -->
<aop:before method="beforeLogin" pointcut-ref="servicePointcut" />
</aop:aspect>
</aop:config>
这样程序可以织入before,但是我想用注解,不用shema配置