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. controller

1.1. extends ActionSupport class

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

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

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

2. view

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

2.2. get path to Webcontent?

2.2.1. ${pageContext.request.contextPath}

2.3. we get values from controller by use ${user.name}

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

3. boostrap

3.1. 1. web.xml

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

3.1.2. default config web.xml for struts 2

3.1.2.1. <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>

3.2. 2. redirect.jsp

3.2.1. it here link to index.jsp

3.3. 3. index.jsp

3.3.1. a link will have

3.3.1.1. namespace - it's folder contain jsp file

3.3.1.2. a link has namespace and action or has only action ex: <s:a namespace="user" action="login">Login</s:a>

3.4. 4. struts.xml have many package

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

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

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

3.4.4. each package have many action

3.4.5. want to add type like html after link?

3.4.5.1. <constant name="struts.action.extension" value="html" />

3.4.6. default config struts.xml

3.4.6.1. <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <!-- Configuration for the default package. --> <package name="default" extends="struts-default"> </package> <include file="struts-tintuc.xml"/> </struts>

3.4.7. want to redirect to a action?

3.4.7.1. in action add parameter type="redirectAction"

4. model

4.1. use JDBC

4.2. use Hibernate FW