Struts Tutorial i: A Struts example of the simplest helloWorld with JBuilder X
This is just a very vulgar example, just a personal record, if you want to learn struts, when you can't find the right example (what? Struts provided by the example is not good?! · #!), Huh, If this is helpful to you, it is really surprise,
The master is best not to watch, huh, :)
premise:
Sometimes, when you learn, you may have a lot of accomplishment to you. When I first studied, I saw the Struts CHM written by my dear. At the time, he used JB writing, WebLogic test,
Very inconvenient, and there are many Struts Tag (labels) in the middle, and the clouds are also seen.
Fortunately, I turned out myself, I finally passed the first level. Write this is also the simplest entry principle
Software requirements: jbuilder x
PS: I just wrote a failure, I k, 9cbs, so unstable, white wrote, hey,
A), build a project with Struts
1. Newly built a HelloWorld project (Project)
2. Create a new WebModule, this is required, everything can be, as follows, as shown below
Note that there is a JavaServer page (JSP file) in the middle.
ActionForm, we will build
Action
JSP from Actionform
3) a webmodule1
4)
Caution to check Struts 1.1
two)
New an actionform1) Actionform named MyActionform
2) Generation from the ADD into the field (username / password),
3) The password of the user name just entered will generate a MyActionForm and Bean
The Get Set user name will be used in our Action.
3) Build a login.jsp, a place to enter a username and password: 1) We create a new JSP from Actionform, Action We are set up for our work
2) The username and password we just entered come in.
3) The login.jsp generated by JB became the case, we changed the change
4) Change to our familiar HTML form submission.
Four) Built an action, myAction1) MyAction
2) This place is very important
3) Generate mapping, the rough figure is the case, wait to add our necessary success to OK.JSP, fail to false.jsp
5) Built two files ok.jsp false.jsp
6) Modify the map we want
OK-> ok.jsp
False-> false.jsp
1) Add to map
2) The last generation is like this
3) The generated struts-config.xml file
You can see the stuff we have just set up.
7) Modify the Action file to determine the correctness of the user input
1) Modify Action
2) Modify this
Eight) Compile: It can be a Tomcat
Enter TestuserName Password TestPassword in Login.jsp
If you see the content of the ok.jsp file correctly
And the content of false.jsp files that are not correct