Escolar Documentos
Profissional Documentos
Cultura Documentos
A basic struts2 application can be made in 7 simple steps. There are umpteen struts2 tutorials on the web so I've refrained from going in a lot of detail about the theoretical information, this article will help you implement the most basic struts2 application in eclipse. I've tried to explain all the steps adequately, providing screenshots and code hints wherever required. It is possible that you may be familiar with a few of the initial steps, but for the benefit of those that maybe the slightest bit confused I've not edited them out. I hope that you find this article to be of use. Please do let me know if you face any issues while implementing this, Id love to help you out, additionally, if you believe that some part of it could be implemented in a better manner Id love to hear of it. Hope this helps.
---------> http://www.versioneye.com/package/org~apache~struts--struts2-
While the exact use of some of these jars may not be evident at first sight, there are many interlinked dependencies which makes it important to include each of the 7 jars, explaining the dependencies would have been out of scope of the post so I skipped the part.
<title>Home</title> </head> <body> <s:form action="Login.action"> <h2>Username : <s:textfield id="username" name = "username"></s:textfield></h2> <s:submit value="Submit"></s:submit> </s:form> </body> </html>
The action attribute mentioned with the form is the keyword which is going to help the application redirect to your action class.
Paste the following code into the new file. Once you click on submit on the Index.jsp, struts.xml sends you over to the mentioned class to the given method. If you do not give a method name in the action tag in struts.xml, the execute ( ) method is called automatically.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <package name="default" extends="struts-default" namespace="/"> <action name="Login" class="com.struts2.action.Login" method="validation"> <result name="success">Success.jsp</result> </action> </package> </struts>