第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

struts2學(xué)習(xí)筆記(1)

標(biāo)簽:
Java

主要内容:
1.struts2的工作原理
2.web.xml的配置说明
3.struts.xml的配置说明

词汇:
filter:过滤器
Interceptors:拦截器
proxy:代理
execute:实施

一、Struts2的工作原理
1.客户发送一个请求。
2.这个请求通过一系列的过滤器。
3.过滤器询问ActionMapper,决定调用那个Action
4.过滤器把调用某个action过的请求交给ActionProxy
5.ActionProxy通过Configuration Manager询问配置文件,找到需要调用的Action类
6.执行该Action类。返回JSP或者FreeMarker给用户

二、实现第一个hello world 例子
(一)创建动态项目。
1)选择tomcat
2)勾选 自动创建web.xml 选项
(二)配置web.xml

<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">
  <display-name>com.yang</display-name>

  <filter>    过滤器
      <filter-name>struts2</filter-name>  加载 struts2过滤器,即StrutsPrepareAndExecuteFilter

      <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>

  <filter-mapping>
     <filter-name>struts2</filter-name>
     <url-pattern>/*</url-pattern>  定义过滤器通知项。这里表示所有的URL都要交给过滤器过滤
  </filter-mapping>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

(三)配置struts.xml文件
1.在src目录下创建struts.xml文件。这点要注意,不然发布的时候会报错。
2.配置

package name="default" namespace="/" extends="struts-default" >    
        <!--//action的配置。重点 -->      
           <!-- 注意这里的action name,它是运行的时候action的名字-->  
        <action name="user" class="action.HelloWorldAction">  这里要注意:前半部分是包名;然后用点号来隔开;后半部分是类名,不要后缀
           <result name="success">/result.jsp</result> 设置返回的jsp页面
        </action> 
    </package>  

(四)发布
注意这里的路径,是怎么构成
http://localhost:8080/com.yang/action/user.action
构成:http://localhost:8080/项目名/包名/action名.action

點(diǎn)擊查看更多內(nèi)容
3人點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消