ไม่ว่าจะสูงแค่ไหนก็ไปถึง











{January 5, 2009}   Struts1 project

ตอนนี้ ทำโปรเจค Struts ซึ่งไม่เคยทำมาก่อน เคยทำแต่ jsf jsp ก็เลยขอจดไว้เป็นบันทึกกันลืมซักหน่อย

1. xml config ของ struts ที่สำคัญมากคือ struts-config.xml ซึ่งภายในจะมีสองส่วนที่สำคัญคือ <form-beans> กับ <action-mappings>

  • <form-beans> บอกว่าใน form นั้นมี property อะไรบ้างที่จะใช้ในหน้า jsp
  • <action-mappings> บอกว่า 1) ตัว class action.java ที่ map กับ path ที่เรียก 2) จาก form นั้น ถ้าได้ผลลัพธ์อย่างนี้ให้ forward ไปไหน

และการจะใช้ struts-config.xml ได้ก็ต้องไปเซตที่ web.xml ซะก่อน (ตัวอย่างหาเอาจากเวบสอนทั่วๆไป)

2. เวลามันเข้า action.java มันจะเข้าที่ fn execute เสมอ (struts1.1 นะ เวอร์ชั่นอื่นไม่แน่ใจ)

Advertisement


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

et cetera
Follow

Get every new post delivered to your Inbox.