Author: Lin Peiwen Some people may think that struts is not easy to learn, some of the concepts seem to let people inside did not come into contact with confusion, MVC1, MVC2, mode ...... I write this article is to make people have never had any contact with the struts, to have a Simple entry guidance, of course, systematically learn Struts is necessary, there are a lot of people who are bothered in Dongdong, that is later. The case includes the home page, the user login, the website wizard page. It's so simple, there is no deep Struts concept, mainly by hand, then experience ~! @ # $% ^ & Web Server with Tomcat4. To http://jakarta.apache.org download struts1.1, release the ZIP file to C: / Struts, copy c: /struts/webapps/struts-example.war to C: / Tomcat4 / WebApps, start Tomcat, The WAR package is released to the Struts-Example folder, remove the WAR package, and rename the Struts-Example folder Test. First, change web-inf / web.xml: XML Version = "1.0" Encoding = "ISO-8859-1"> -> Under normal circumstances, after an Action is processed, it is forwarded to a JSP page for display. This is also the point of implementation of MVC in JSP. -> -> public final class RegistAction extends Action {public ActionForward execute (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {Locale locale = getLocale (request); MessageResources messages = getResources (request); HttpSession session = request.getSession () Userform userform = (userform) form; // You can call other classes to execute database write or other logic judgment // If the usermm transmitted by the parameter Name of Name is the default LPW, will forward to failed, // The name will find a mapped URL address / / (which can be an absolute path, or a relative path), for this example, is transferred to failed.cool, // Remember ? The suffix is a request for Cool to find // corresponding to // in action-mapings, the final directory is wuw.jsp * / if ("lpw" .Equals (userform.getname ()) Return (Mapping.Findforward ("failed ")); Else Return (" regist "));}} 5, all newly added or modified pages are equivalent to Struts's View section, change the home page index.jsp: <% @ page contenttype = "text / html; charSet = GBK" language = "java"%> <% @ page import = "test. *"%> site navigation Will go to this page: <% @ page contenttype = "text / html; charset = GBK" language = "java"%>
password:
form> 6, add hello.jsp, for site navigation: site map h1> The following is content Filling by Reader Seven, increasing wuw.jsp, when no new user logs in,
Password: <% = beanlpw.getps ()%>
Nothing to get new users! 55555 ~~~~~ 8, increase regist.jsp, when there is a new user login, turn to this page: <% @ page contentType = "text / html; charset = GBK" language = "java"%>
password: <% = beanlpw.getps ()%> Nine, start Tomcat4, type http: // localhost: 8080 / test / index.jsp, you can see the result, and initially understand the synergy of the Struts M, V, and of course This is the author's good wish. If the reader can see a mist, welcome to indicate where the error is :) Reprinted from: http://www.javaresearch.org/article/showArticle.jsp? Column = 23 & thread = 10265