學習strut2的心得

來源:互聯網
上載者:User

   怎麼樣學習好strut2呢?

  看了一些視頻,學了十天的struts2,也做了一個很小的項目,增加,改、刪除,查功能。覺得要入門struts2,首先的是學會配置strut2的架構。結著是web.xml的檔案,一般都不會變的。

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>struct2</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
 
  <!-- struts配置 -->
 <filter>
  <filter-name>struts2</filter-name><!-- StrutsPrepareAndExecuteFilter  --><!-- FilterDispatcher -->
  <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>

 

然後就是就是struts.xml的檔案,要學會看懂,並且會配置。注意一點的是瀏覽網頁的時候要用結合struts.xml配置裡面的路徑用,訪問Action的URL是與<package>元素namespace屬性的值相關的。即http://IP:port/web應用程式名稱/namespace/Action名字.action.

要養成一種習慣(要不然,你用標籤的時候,讀不出資料庫的資料)。還有我就覺得學點struts2的標籤,一般看協助文檔就可以用了。最後,你會連結資料庫就行了。基本是這樣

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.