【发布时间】:2014-07-14 10:01:25
【问题描述】:
我试图将 AOP 记录器添加到现有的 Spring(v3.1.3) 应用程序中。下面是相同的代码。 应用程序成功启动并能够登录。但是,一旦流程到达 ApplicationLogger.java 中指定的控制器,屏幕上就会出现 404 错误,不幸的是控制台中没有任何错误跟踪。没有得到任何线索。
请帮我找出我哪里出错了。
TIA, 阿伦
SERVLET.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd" >
<context:annotation-config />
<mvc:annotation-driven />
<!-- Enables the caching through annotations -->
<cache:annotation-driven />
<aop:aspectj-autoproxy />
<bean id="appLogger"
class="com.pmc.crm.risk.util.ApplicationLogger" />
.
.
.
ApplicationLogger.java
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
@Aspect
public class ApplicationLogger
{
/**
* Log method entry.
*
* @param joinPoint
*/
@Before("execution(* com.pmc.crm.risk.mvc.controller.SearchController.loadParamSearch(..))")
public void logEntry(final JoinPoint joinPoint)
{
System.out.println("*--*-*-*-* LOG ENTRY -*-*-*");
log("Entering method " + joinPoint.getSignature().getName() + "...");
}
/**
* Log method exit.
*
* @param joinPoint
*/
@After("execution(* com.pmc.crm.risk.mvc.controller.SearchController.loadParamSearch(..))")
public void logExit(final JoinPoint joinPoint)
{
System.out.println("*--*-*-*-* LOG EXIT -*-*-*");
log("Exiting method " + joinPoint.getSignature().getName() + ".");
}
SEARCHCONTROLLER.java
package com.pmc.crm.risk.mvc.controller;
import ....
@Controller
public class SearchController extends AbstractPolicyController{
private static final Logger LOG = Logger.getLogger(SearchController.class);
@RequestMapping(value = "/loadParamSearch.htm", method = RequestMethod.GET)
public ModelAndView loadParamSearch(HttpServletRequest request, HttpServletResponse response,ModelMap model) throws Exception{
try
{
System.out.println("...");
}
.
.
【问题讨论】:
-
嗨,我解决了这个问题。这里适用于将来在同一问题上登陆的任何人:AbstractPolicyController 实际上正在实现一个接口,而 servlet 无法为该接口注入代理(正在调查原因。)在删除“实现 interfaceName”时效果很好。知道原因的朋友可以告诉我。
-
您应该将此评论作为答案发表
标签: spring logging http-status-code-404 aop