You are here
Home > Programming > Java > Struts2 > Tutorial Message Store Interceptor Apache Struts2

Tutorial Message Store Interceptor Apache Struts2

Tutorial Message Store Interceptor Apache Struts2

Kita lanjutkan belajar struts2 dengan judul Tutorial Message Store Interceptor Apache Struts2. Mari kita lihat apa itu message store interceptor:

An interceptor to store a ValidationAware action’s messages / errors and field errors into HTTP Session, such that it will be retrievable at a later stage. This allows the action’s message / errors and field errors to be available longer that just the particular HTTP request. sumber: apache struts

Sekarang ayo kita mulai Tutorial Message Store Interceptor Apache Struts2:

  • Buka folder workspace anda, jangan lupa pelajari dulu Tutorial Basic Apache Struts2. Karena kita akan melanjutkan source codenya.
  • Buat folder “message-store-struts2” di workspace anda
  • Copy file “pom.xml” dan folder “src” di folder “basic-struts2” tutorial sebelumnya.
  • Buka file “pom.xml”, rubah artifact-id “basic-struts2” ke “message-store-struts2”
  • Rubah juga tag name dan description “Belajar Message Store Interceptor Struts2”
  • Buka IDE eclipse
  • Pilih import >> existing maven project >> browse ke folder “message-store-struts2” >> finish
  • Project baru message-store-struts2 sudah berhasil di load

Mari kita mulai melakukan perubahan selanjutnya

  • Create package “com.wijaksana.belajar.struts2.action”
  • Tambahkan class sebagai controller/action dengan nama “HelloWorld1Action” di package “com.wijaksana.belajar.struts2.action” dan tambah extend “ActionSupport”
  • Tambahkan @Override method “execute”
  • Tambahkan script dibawah ini pada method “execute”
  • Tambahkan class sebagai controller/action dengan nama “HelloWorld2Action” di package “com.wijaksana.belajar.struts2.action” dan tambah extend “ActionSupport”
  • Tambahkan @Override method “execute”
  • Tambahkan script dibawah ini pada method “execute”
  • Create file xml dengan nama “message-store.xml” (src/main/resources), lalu tambahkan script dibawah ini:
  • Buka file struts.xml (src/main/resources), replace script didalam tag <struts> dengan script dibawah ini:

Leave a Reply

Top