怎麼樣學習好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的標籤,一般看協助文檔就可以用了。最後,你會連結資料庫就行了。基本是這樣