Article directory
foreword
Record ssh framework learning
1. What is Strust2? What's the use?
Struts2 is a framework for implementing MVC , based on the WebWork framework technology. The struts2 core interceptor, the core functions of the struts2 framework are all implemented by the interceptor .
Role:
strust2 can automatically realize the transmission and transmission of data requests, that is, request and response are no longer needed
Essence:
Servlet implemented by filters
2. Strust2 initialization
1. trust.xml (put in src)
<?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" namespace="/" extends="struts-default"><!-- struts-default是strust2自带的包 -->
<action name="" class="" method=""> <!--name 相当于servlet的/aa/a--!> <!--class 相当于对那个包继续操作--> <!--method调用改包的那个方法-->
<result name=""></result> <!--name 执行该方法的返回结果-->
<result name=""></result>
</action>
</package>
</struts>
2.web.xml
code show as below:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Functional Structure Diagram
功能结构如下所示:
Getting Started Case
Requirements Analysis: Realize the summation
code of positive and negative numbers and installation and deployment