4.

【Spring】@Beforeアノテーションとは

ページの作成
テンプレートを更新

ページの作成

親となるページを選択してください。

ページは必ず何かしらの親ページに紐づきます。
親ページに紐づくページを子ページといいます。
例: 親=スポーツ, 子1=サッカー, 子2=野球

子ページを親ページとして更に子ページを作成することも可能です。
例: 親=サッカー, 子=サッカーのルール

親ページはいつでも変更することが可能なのでとりあえず作ってみましょう!

本稿はSpringFrameworkの@Beforeについて説明します。

@Beforeとは

@Beforeはメソッド単位で付与するアノテーションです。

@Beforeは@Acpectが付与されたクラス内で使用されます。

@Beforeが付与されたクラスは、execution内の条件に当てはまる場合、対象の処理の実行前に@Beforeメソッドが実行されます。

※AOPに関してはこちらを参照。

以下、@Beforeを使用したサンプルです。

@Aspect
@Component
public class TestAOP {

    @Before("execution(* com.example.springmvc2.*.*(..))")
    public void before(JoinPoint joinPoint) {
        System.out.println("Method Start:"  + joinPoint.getSignature());
    }

    @After("execution(* com.example.springmvc2.*.*(..))")
    public void after(JoinPoint joinPoint) {
        System.out.println("Method End:"  + joinPoint.getSignature());
    }
}

 

子ページ
子ページはありません
同階層のページ
  1. @After
  2. @Autowired
  3. @Bean
  4. @Before
  5. @Column
  6. @Component
  7. @Configuration
  8. @Controller
  9. @Data
  10. @Entity
  11. @GeneratedValue
  12. @Id
  13. @Modifying
  14. @PathVariable
  15. @PropertySource
  16. @Repository
  17. @RequestBody
  18. @RequestMapping
  19. @ResponseBody
  20. @RestController
  21. @Service
  22. @SpringBootApplication
  23. @Table
  24. @Transactional
  25. @Value

最近の質問

コメント一覧

コメントがありません

ログインしなければコメント投稿はできません。