Struts 2 Framework

Get Started. It's Free
or sign up with your email address
Struts 2 Framework by Mind Map: Struts 2 Framework

1. boostrap

1.1. 1. web.xml

1.1.1. find to welcome-file, normal is redirect.jsp

1.1.2. default config web.xml for struts 2 <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list>

1.2. 2. redirect.jsp

1.2.1. it here link to index.jsp

1.3. 3. index.jsp

1.3.1. a link will have namespace - it's folder contain jsp file a link has namespace and action or has only action ex: <s:a namespace="user" action="login">Login</s:a>

1.4. 4. struts.xml have many package

1.4.1. at struts wil catch action value from link, after redirect to controller

1.4.2. struts.xml will catch string return at controller and match with result tag name

1.4.3. each package is a namespace, ex: /user main namespace is "/"

1.4.4. each package have many action

1.4.5. want to add type like html after link? <constant name="struts.action.extension" value="html" />

1.4.6. default config struts.xml <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" ""> <struts> <!-- Configuration for the default package. --> <package name="default" extends="struts-default"> </package> <include file="struts-tintuc.xml"/> </struts>

1.4.7. want to redirect to a action? in action add parameter type="redirectAction"

2. controller

2.1. extends ActionSupport class

2.2. if don't specify method in action, execute method will be run

2.3. after then, a method will return a string ex: "addOrEdit" it will be catched at struts.xml

2.4. to pass values to view, we create a private variable and gets-sets for it

3. view

3.1. <%@taglib prefix="s" uri="/struts-tags" %>

3.2. get path to Webcontent?

3.2.1. ${pageContext.request.contextPath}

3.3. we get values from controller by use ${}

3.4. to assigns value in form to model, we set name parameter name is ${}

4. model

4.1. use JDBC

4.2. use Hibernate FW