日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Struts2学习第三课 Struts2详解

發布時間:2025/3/15 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Struts2学习第三课 Struts2详解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

接著上次的課程

這次我們看struts.xml

修改如下:這里是加上命名空間,默認的是不加,我們手動加上時就要在訪問時加上命名空間。

<?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:包,struts2使用package來組織模塊name屬性:必須,用于其他包引用當前包extends: 當前包繼承哪個包,繼承的,即可以繼承其中的所有的配置,通常情況下繼承struts-defaultstruts-default這個包在struts-default.xml文件中定義的--><package name="helloWorld" extends="struts-default" namespace="/logan"><!-- 配置action:一個struts2的請求就是一個actionname:對應一個Struts2的請求的名字,不包含擴展名 --><action name="product-input"><result>/WEB-INF/pages/input.jsp</result></action><action name="product-save" class="logan.struts.study.Product" method="save"><result name="details">/WEB-INF/pages/details.jsp</result></action></package></struts>

我們再去訪問地址http://localhost:8080/Struts2-2/product-input.action

可以看到訪問失敗

HTTP Status 404 - There is no Action mapped for namespace [/] and action name [product-input] associated with context path [/Struts2-2].type Status reportmessage There is no Action mapped for namespace [/] and action name [product-input] associated with context path [/Struts2-2].description The requested resource is not available.Apache Tomcat/9.0.0.M15

我們訪問這個地址才能訪問:http://localhost:8080/Struts2-2/logan/product-input.action

action里面class的默認值是com.opensymphony.xwork2.ActionSupport

默認的執行方法時execute

result:結果,表示action方法執行后可能返回的一個結果。所以一個action節點可能會有多個result子節點。多個result子節點使用name來區分。

name:標識一個result,和cation方法的返回值對應,的默認值是success。

type:表示結果的類型,默認值為dispatcher(轉發到結果)

?

轉載于:https://www.cnblogs.com/LoganChen/p/6942304.html

總結

以上是生活随笔為你收集整理的Struts2学习第三课 Struts2详解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。