這是DPCTYPE
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
這是beans裡的配置
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
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.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
這是我接下來的通知類
<bean id="advices" class="advice.Advices"></bean>
<aop:config>
<!-- 調用日志類 -->
<aop:aspect id="advice" ref="advices">
<aop:pointcut expression="execution(* action.*.*(..))" id="log"/>
<aop:before method="before" pointcut-ref="log"/>
<aop:after method="afterReturning" pointcut-ref="log"/>
<aop:after-throwing method="afterThrowing" pointcut-ref="log"/>
</aop:aspect>
</aop:config>
但是用tomcat運行下來會報這個錯
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [xml/spring-advice.xml]
Offending resource: ServletContext resource [/WEB-INF/classes/applicationContext.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from ServletContext resource [/WEB-INF/classes/xml/spring-advice.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Attribute "xmlns" must be declared for element type "beans".
Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from ServletContext resource [/WEB-INF/classes/xml/spring-advice.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Attribute "xmlns" must be declared for element type "beans".
Caused by: org.xml.sax.SAXParseException: Attribute "xmlns" must be declared for element type "beans".
xmlns="http://www.springframework.org/schema/beans" 加上這個