main
刘思晗 2 weeks ago
parent a05cf1463f
commit 0478b7f7cd

@ -19,5 +19,7 @@
<orderEntry type="library" name="spring-context-5.1.6.RELEASE (3)" level="project" />
<orderEntry type="library" name="spring-core-5.1.6.RELEASE (2)" level="project" />
<orderEntry type="library" name="spring-expression-5.1.6.RELEASE (2)" level="project" />
<orderEntry type="library" name="com.springsource.org.aopalliance-1.0.0" level="project" />
<orderEntry type="library" name="com.springsource.org.aspectj.weaver-1.6.8.RELEASE" level="project" />
</component>
</module>

@ -0,0 +1,22 @@
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
https://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd">
<!-- 开启注解扫描 -->
<context:component-scan base-package="com.ssm.aop"/>
<!-- 开启AOP自动代理 -->
<aop:aspectj-autoproxy/>
<!-- 注册Bean -->
<bean id="cls" class="com.ssm.aop.Class"/>
</beans>

@ -0,0 +1,20 @@
package com.ssm.aop;
public class Class {
private Integer cid;
private String cname;
private Integer num;
public Integer getCid() {return cid;}
public void setCid(Integer cid) {this.cid = cid;}
public String getCname() {return cname;}
public void setCname(String cname) {this.cname = cname;}
public Integer getNum() {return num;}
public void setNum(Integer num) {this.num = num;}
public void show(){
System.out.println("班级id"+cid);
System.out.println("班级名称:"+cname);
System.out.println("班级人数:"+num);
}
}

@ -0,0 +1,14 @@
package com.ssm.aop;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class Log {
@Before("execution(* com.ssm.aop.*.show())")
public void beforeAdvice(){
System.out.println("【前置通知】方法即将执行");
}
}

@ -10,7 +10,6 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Controller
@ -42,7 +41,7 @@ public class DemoController {
}
//添加成功
@RequestMapping("addOk")
public String addok(Demo demo, HttpServletRequest request) throws Exception {
public String addok(Demo demo) throws Exception {
System.out.println(demo);
demoService.addDemo(demo);
return "redirect:/demo/findAllByPage.action?page=1";
@ -56,7 +55,7 @@ public class DemoController {
}
//demo更新成功
@RequestMapping("updateOk")
public String updateOk(Demo demo, HttpServletRequest request) throws Exception{
public String updateOk(Demo demo) throws Exception{
System.out.println(demo);
demoService.updateDemo(demo);
return "redirect:/demo/findAllByPage.action?page=1";

Loading…
Cancel
Save