我有一个非常简单的设置
我有一个applicationContext.xml
这样的文件:
<context:component-scan base-package="com.mkyong.common.controller" />
<bean id="customizableTraceInterceptor"
class="org.springframework.aop.interceptor.CustomizableTraceInterceptor">
<property name="enterMessage" value="Entering $[methodName]($[arguments])" />
<property name="exitMessage" value="Leaving $[methodName](): $[returnValue]" />
</bean>
<bean
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>*Service</value>
</list>
</property>
<!-- <property name="proxyTargetClass" value="true" /> -->
<property name="interceptorNames">
<list>
<value>customizableTraceInterceptor</value>
</list>
</property>
</bean>
<mvc:annotation-driven />
<bean id="wowService" class="org.daud.WowService" scope="prototype" />
</beans>
控制器类也很简单:
@Controller
@RequestMapping("/welcome")
public class HelloController {
@Autowired
private WowService wowService;
@RequestMapping(method = RequestMethod.GET)
public String printWelcome(ModelMap model) {
getWowService().printIt();
model.addAttribute("message", "Spring 3 MVC Hello World");
return "hello";
}
public WowService getWowService() {
return wowService;
}
public void setWowService(WowService wowService) {
this.wowService = wowService;
}
}
web.xml 是:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_3_0.xsd"
version="3.0" metadata-complete="true">
<display-name>simple-form</display-name>
<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>
<servlet>
<servlet-name>simple-form</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>simple-form</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
WowService
也很简单
public class WowService {
public String printIt() {
return "daud";
}
}
我有spring jars of version 3.0.6
,aopalliance-1.0.jar
和commons-logging-1.1.1.jar
在我的 lib 文件夹中,没有别的。但是没有记录任何痕迹.. 即当我们进入 的方法WowService
或离开它时,没有记录。我不知道为什么。