隨筆-34  評(píng)論-1965  文章-0  trackbacks-0

          Struts作為MVC 2的Web框架,自推出以來不斷受到開發(fā)者的追捧,得到用廣泛的應(yīng)用。作為最成功的Web框架,Struts自然擁有眾多的優(yōu)點(diǎn):

          • MVC 2模型的使用
          • 功能齊全的標(biāo)志庫(Tag Library)
          • 開放源代碼

          但是,所謂“金無赤金,人無完人”,Struts自身也有不少的缺點(diǎn):

          • 需要編寫的代碼過多,容易引起“類爆炸”
          • 單元測(cè)試?yán)щy

          這些缺點(diǎn)隨著Web的發(fā)展越來越明顯。這就促生了Struts 2.0,它的誕生能很好的解決上述問題。 好啦,廢話就不多說了,現(xiàn)在就讓我們感受一下的Struts 2.0的魅力吧。

          1. 搭建開發(fā)和運(yùn)行環(huán)境
            1. 到Apache下載Struts 2.0包

            2. 打開Eclipse 3.2新建Web工程

              點(diǎn)擊菜單File\New\Project,出現(xiàn)如圖1所示對(duì)話框
              圖1 新建工程對(duì)話框
              圖1 新建工程對(duì)話框
              選擇Web\Dynamic Web Project,點(diǎn)擊“Next”,出現(xiàn)圖2對(duì)話框

              圖2 新建動(dòng)態(tài)Web工程對(duì)話框
              圖2 新建動(dòng)態(tài)Web工程對(duì)話框
              在“Project Name”中鍵入Struts2_HelloWorld,點(diǎn)擊“New”,出現(xiàn)以下對(duì)話框

              圖3 新建服務(wù)器運(yùn)行時(shí)對(duì)話框
              圖3 新建服務(wù)器運(yùn)行時(shí)對(duì)話框
              選擇“Apache\Apache Tomat v5.5”,點(diǎn)擊“Next”,出現(xiàn)以下對(duì)話框

              圖4新建服務(wù)器運(yùn)行時(shí)對(duì)話框
              圖4新建服務(wù)器運(yùn)行時(shí)對(duì)話框
              點(diǎn)擊“Finish”,關(guān)閉對(duì)話框。

            3. 將Struts 2.0 lib下的jar文件加到工程的構(gòu)建路徑(build path)

              圖5 Struts 2.0的lib目錄
              圖5 Struts 2.0的lib目錄
              按ctr+a全選,復(fù)制,再轉(zhuǎn)到Eclipse窗口,在“Project Explorer”子窗口中選中Struts2_HelloWorld\WebContent\WEB-INF\lib,然后粘貼。經(jīng)過Eclipse自動(dòng)刷新“Project Explorer”子窗口,剛才所粘貼的jar文件應(yīng)該會(huì)出現(xiàn)在Struts2_HelloWorld\Java Resources: src\Libraries\Web App Libraries下,如圖6所示:

              圖6 Project Explorer子窗口
              圖6 Project Explorer子窗口

            4. 打開web.xml文件,將其修改為以下代碼:
              <?xml?version="1.0"?encoding="ISO-8859-1"?>
              <!DOCTYPE?web-app?PUBLIC?"-//Sun?Microsystems,?Inc.//DTD?Web?Application?2.3//EN"?"http://java.sun.com/dtd/web-app_2_3.dtd">
              <web-app>
              ????
              <display-name>Struts?2.0?Hello?World</display-name>
              ????
              <filter>
              ????????
              <filter-name>struts2</filter-name>????????<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
              ????
              </filter>
              ????
              <filter-mapping>
              ????????
              <filter-name>struts2</filter-name>
              ????????
              <url-pattern>/*</url-pattern>
              ????
              </filter-mapping>
              ????
              <welcome-file-list>
              ????????
              <welcome-file>index.html</welcome-file>
              ????
              </welcome-file-list>
              </web-app>

            5. 新建struts.xml文件

              右鍵點(diǎn)擊,Struts2_HelloWorld\Java Resources: src,出現(xiàn)如圖7所示菜單
              圖7 新建Other菜單
              圖7 新建Other菜單
              點(diǎn)擊“Other”,出現(xiàn)新建對(duì)話框,如圖8所示

              圖8 新建對(duì)話框
              圖8 新建對(duì)話框
              點(diǎn)擊“Next”,出現(xiàn)新建文件對(duì)話框,如圖9所示

              圖9 新建文件對(duì)話框
              圖9 新建文件對(duì)話框
              在“File name”中鍵入sturts.xml,點(diǎn)擊“Finish”,然后將struts.xml的內(nèi)容修改為:

              <!DOCTYPE?struts?PUBLIC
              ????????"-//Apache?Software?Foundation//DTD?Struts?Configuration?2.0//EN"
              ????????"http://struts.apache.org/dtds/struts-2.0.dtd"
              >
              <struts>
              ????
              <include?file="struts-default.xml"/>
              </struts>

            6. 新建index.html文件

              右鍵點(diǎn)擊Struts2_HelloWorld\WebContent,出現(xiàn)如圖10所示的菜單
              圖10 新建Other菜單
              圖10 新建Other菜單
              點(diǎn)擊“Other”,出現(xiàn)新建對(duì)話框,如圖11所示

              圖11 新建對(duì)話框
              圖11 新建對(duì)話框
              選擇Web\HTML,點(diǎn)擊“Next”出現(xiàn)如圖12所示的對(duì)話框

              圖12 新建HTML頁面對(duì)話框
              圖12 新建HTML頁面對(duì)話框
              在“File Name”中鍵入index.html,點(diǎn)擊“Next”,出現(xiàn)如圖13所示的對(duì)話框

              圖13 模板選擇對(duì)話框
              圖13 模板選擇對(duì)話框
              點(diǎn)擊“Finish”,將index.html的內(nèi)容修改為以下內(nèi)容:

              <!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN">
              <html>
              <head>
              <meta?http-equiv="Content-Type"?content="text/html;?charset=UTF-8">
              <title>Hello?World</title>
              </head>
              <body>
              <h3>Hello?World!</h3>
              </body>
              </html>

            7. 將應(yīng)用程序打包到tomcat上

              右鍵點(diǎn)擊Struts_HelloWorld,出現(xiàn)如圖14所示的菜單
              圖14 工程菜單
              圖14 工程菜單
              點(diǎn)擊“Export\WAR file”,出現(xiàn)如圖15所示的對(duì)話框

              圖15 輸出對(duì)話框
              圖15 輸出對(duì)話框
              選擇“Web\WAR file”,點(diǎn)擊“Next”,出現(xiàn)如圖16所示的對(duì)話框

              圖16 輸出路徑對(duì)話框
              圖16 輸出路徑對(duì)話框
              輸入war文件的路徑(如%tomcat%\webapps\Struts2_HelloWorld.war),點(diǎn)擊“Finish”關(guān)閉對(duì)話框。

            8. 啟動(dòng)tomcat,運(yùn)行應(yīng)用程序

              打開你的Internet Explorer,鍵入http://localhost:8080/Struts2_HelloWorld/,窗口輸出如圖17所示
              圖17 Hello World窗口
              圖17 Hello World窗口

          2. 第一個(gè)Struts 2.0應(yīng)用程序——Hello World
            1. 新建類包(package)

              右鍵點(diǎn)擊Struts2_HelloWorld\Java Resources: src,出現(xiàn)如圖18所示菜單
              圖18 新建菜單
              圖18 新建菜單"
              點(diǎn)擊“New\Package”,出現(xiàn)如圖19所示對(duì)話框

              圖19新建Java類包對(duì)話框
              圖19新建Java類包對(duì)話框
              在“Name”鍵入tutorial,點(diǎn)擊“Finish”關(guān)閉對(duì)話框。

            2. 新建HelloWorld.java文件

              右鍵點(diǎn)擊Struts2_HelloWorld\Java Resources: src\tutorial,出現(xiàn)如圖20所示菜單
              圖20 新建菜單
              圖20 新建菜單
              點(diǎn)擊“New\Class”,出現(xiàn)如圖21所示對(duì)話框

              圖21 新建Java類對(duì)話框
              圖21 新建Java類對(duì)話框
              在“Name”中鍵入HelloWorld,在“Superclass”中鍵入com.opensymphony.xwork2.ActionSupport,點(diǎn)擊“Finish”關(guān)閉對(duì)話框。將HelloWorld.java的內(nèi)容修改為:

              package?tutorial;

              import?com.opensymphony.xwork2.ActionSupport;

              public?class?HelloWorld?extends?ActionSupport?{
              ????
              private?String?name;
              ????
              ????
              public?String?getName()?{
              ????????
              return?name;
              ????}

              ????
              ????
              public?void?setName(String?name)?{
              ????????
              this.name?=?name;
              ????}

              ????
              ????
              public?String?execute()?{
              ????????name?
              =?"Hello,?"?+?name?+?"!";?
              ????????
              return?SUCCESS;
              ????}

              }

            3. 在struts.xml中添加action映射(mapping)
              <!DOCTYPE?struts?PUBLIC
              ????????"-//Apache?Software?Foundation//DTD?Struts?Configuration?2.0//EN"
              ????????"http://struts.apache.org/dtds/struts-2.0.dtd"
              >
              <struts>
              ????
              <include?file="struts-default.xml"/>
              ????
              <package?name="tutorial"?extends="struts-default">
              ????????
              <action?name="HelloWorld"?class="tutorial.HelloWorld">
              ????????????
              <result>HelloWorld.jsp</result>
              ????????
              </action>
              ????
              </package>
              </struts>

            4. 新建SayHello.jsp

              參考“新建index.html文件”步驟,彈出如圖22所示對(duì)話框
              圖22 新建對(duì)話框
              圖22 新建對(duì)話框
              點(diǎn)擊“Next”, 進(jìn)入下一步,如圖23所示

              圖23 新建JSP對(duì)話框
              圖23 新建JSP對(duì)話框
              在“File name”鍵入SayHello.jsp,點(diǎn)擊“Next”進(jìn)入下一步,如圖24所示

              圖24 模板選擇對(duì)話框
              圖24 模板選擇對(duì)話框
              點(diǎn)擊“Finish”關(guān)閉對(duì)話框,并將SayHello.jsp的內(nèi)容修改為:

              <%@?page?contentType="text/html;?charset=UTF-8"?%>
              <%@?taglib?prefix="s"?uri="/struts-tags"?%>
              <!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN">
              <html>
              ????
              <head>
              ????????
              <title>Say?Hello</title>
              ????
              </head>
              ????
              <body>
              ????????
              <h3>Say?"Hello"?to:?</h3>
              ????????
              <s:form?action="HelloWorld">
              ????????????Name:?
              <s:textfield?name="name"?/>
              ????????????
              <s:submit?/>
              ????????
              </s:form>
              ????
              </body>
              </html>

            5. 新建HelloWorld.jsp(請(qǐng)參考上一步),HelloWorld.jsp的內(nèi)容為:
              <%@?page?contentType="text/html;?charset=UTF-8"?%>
              <%@?taglib?prefix="s"?uri="/struts-tags"?%>
              <!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN">
              <html>
              ????
              <head>
              ????????
              <title>Hello</title>
              ????
              </head>
              ????
              <body>
              ????????
              <h3><s:property?value="name"?/></h3>
              ????
              </body>
              </html>

            6. 重新打包發(fā)布應(yīng)用程序

              先停止tomcat, 再將tomcat里webapps下的Struts2_HelloWorld.war和Struts2_HelloWorld文件夾刪除,參照“將應(yīng)用程序打包到tomcat上”重新發(fā)布應(yīng)用程序。

            7. 啟動(dòng)tomcat,運(yùn)行測(cè)試

              打開Internet Explorer,鍵入http://localhost:8080/Struts2_HelloWorld/SayHello.jsp,窗口輸出如圖25所示
              圖25 SayHello.jsp
              圖25 SayHello.jsp
              在“Name”鍵入字符串(如World),點(diǎn)擊Submit,轉(zhuǎn)到HelloWorld.jsp頁面,如圖26所示

              圖26 HelloWorld.jsp
              圖26 HelloWorld.jsp

          3. 單元測(cè)試Hello World

            在文章開始的時(shí)候提及,單元測(cè)試?yán)щy是Struts一大缺點(diǎn)。現(xiàn)在讓我們?cè)隗w驗(yàn)一下,在Struts 2.0中是如何進(jìn)行測(cè)試的。

            1. 新建JUnit單元測(cè)試

              右鍵點(diǎn)擊Struts2_HelloWorld\Java Resources: src\tutorial,彈出如圖27所示對(duì)話框
              圖27 新建菜單
              圖27 新建菜單
              點(diǎn)擊“Next\Other”

              圖28 新建對(duì)話框
              圖28 新建對(duì)話框
              選擇“Java\JUnit\JUnit Test Case”,點(diǎn)擊“Next”

              圖29 新建JUnit 測(cè)試用例對(duì)話框
              圖29 新建JUnit 測(cè)試用例對(duì)話框
              選擇“New JUnit 4 test”,在“Name”中鍵入HelloWorldTest,在“Class under test”鍵入tutorial.HelloWorld,點(diǎn)擊“Next”

              圖30 選擇方法對(duì)話框
              圖30 選擇方法對(duì)話框
              選中HelloWorld\execute方法,點(diǎn)擊Finish。如果生成的HelloWorldTest.java文件的圖標(biāo)(Icon)出現(xiàn)紅色交叉標(biāo)志,請(qǐng)進(jìn)行以下步驟添加JUnit 4的jar包。

              右鍵點(diǎn)擊Struts2_HelloWorld,出現(xiàn)如圖所示菜單。 圖31 新建菜單
              圖31 新建菜單
              點(diǎn)擊“Build Path\Add Libararis”,彈出圖32對(duì)話框

              圖32 添加庫對(duì)話框
              圖32 添加庫對(duì)話框
              選中“JUnit”,點(diǎn)擊“Next”

              圖33 選擇版本對(duì)話框
              圖33 選擇版本對(duì)話框
              選擇“JUnit 4”,點(diǎn)擊“Finish”關(guān)閉對(duì)話框,并將HelloWorldTest.java的內(nèi)容修改為:

              package?tutorial;

              import?static?org.junit.Assert.assertTrue;

              import?org.junit.Test;

              import?com.opensymphony.xwork2.ActionSupport;

              public?class?HelloWorldTest?{

              ????@Test
              ????
              public?void?testExecute()?{
              ????????HelloWorld?hello?
              =?new?HelloWorld();
              ????????hello.setName(
              "World");
              ????????String?result?
              =?hello.execute();
              ????????
              ????????assertTrue(
              "Expected?a?success?result!",?ActionSupport.SUCCESS.equals(result));
              ????????
              ????????
              final?String?msg?=?"Hello,?World!";
              ????????assertTrue(
              "Expected?the?default?message!",?msg.equals(hello.getName()));
              ????}


              }

            2. 運(yùn)行單元測(cè)試

              右鍵點(diǎn)擊Struts2_HelloWorld\Java Resources: src\tutorial\HelloWorldTest.java,彈出如圖34所示菜單
              圖34 運(yùn)行為菜單
              圖34 運(yùn)行為菜單
              點(diǎn)擊“Run As\JUnit Test”,出現(xiàn)JUnit子窗口如圖35所示

              圖35 JUnit子窗口
              圖35 JUnit子窗口
              圖35的綠色矩形表示,所有單元測(cè)試通過。

          4. 總結(jié)

            上面的例子簡(jiǎn)單地演示了,Web 應(yīng)用程序的基本操作,也即是,頁面輸入->Action處理->再輸出到另外頁面。Struts 2.0的簡(jiǎn)單易用、方便測(cè)試相信也會(huì)給大家留下不錯(cuò)的印象吧。我相信,Struts 2.0作為一個(gè)全新的Web架構(gòu),將會(huì)再次掀起Web開發(fā)的熱潮。 不過,Struts 2.0還在測(cè)試中,正式版的發(fā)布還需些時(shí)日,所以文檔方面可能有所欠缺。請(qǐng)大家繼續(xù)留意我的博客,我會(huì)盡我所能為大家寫更多關(guān)于Struts 2.0的文章。

          posted on 2006-10-10 18:35 Max 閱讀(126043) 評(píng)論(345)  編輯  收藏 所屬分類: Struts 2.0系列
          評(píng)論共4頁: 1 2 3 4 下一頁 

          評(píng)論:
          # re: 為Struts 2.0做好準(zhǔn)備 2008-04-14 19:04 | 極度郁悶
          按照步驟配置了,但SayHello.jsp提交失敗,后臺(tái)總是報(bào)錯(cuò)“no configuration found for the specified action...”,試了無數(shù)次,google了半天,還是不行,最后終于極度郁悶的發(fā)現(xiàn),配置文件名稱是“sturts.xml”,這個(gè)名稱是從你文章里拷過去的,有一個(gè)字母順序錯(cuò)了,狂暈!!!浪費(fèi)了近3個(gè)小時(shí),555555555555555.............  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2008-04-21 18:00 | lf
          以前一直都用的struts1.X, 學(xué)習(xí)下!
          設(shè)置一切OK,綠色順利出來
          不錯(cuò),支持  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-04-21 20:49 | sidekick
          No configuration found for the specified action: 'HelloWorld' in namespace

          是因?yàn)?copy 'sturts.xml' 的結(jié)果, 請(qǐng)更正文章中 sturts.xml 為 struts.xml

          sturts.xml --> struts.xml  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-04-23 17:15 | 懶人
          和1.0差在哪?不能出了新技術(shù)就什么地方都用吧?  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-04-29 17:26 | snowwolf76
          寫得太棒了。
          我用的struts-2.0.11.1+jdk1.6.0_05+tomcat 5.5.26.
          關(guān)于404的錯(cuò)誤,我是先把所有struts2的jar文件粘貼到lib目錄下,然后把struts2-spring-plugin-2.xxx.jar,
          struts2-plexus-plugin-2.xxx.jar,
          struts2-jsf-plugin-2.xxx.jar刪除,
          還對(duì)照截圖刪除了antlr-2xxx.jar, commons開頭的幾個(gè)jar(也許不是他們的原因),因?yàn)槲沂窃趀clipse里面debug工程看到了些異常。  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-04-30 11:44 | goldgood
          在此頁面中的,java源程序的樹形結(jié)構(gòu),是如何實(shí)行的?  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-05-04 14:30 | goldgood
          問題解決。  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-05-07 11:26 | 傳說中的???
          關(guān)于第1次啟動(dòng)時(shí)就報(bào)HTTP404錯(cuò)的解決方法
          錯(cuò)誤信息:
          2008-5-7 11:17:24 org.apache.catalina.core.StandardContext start
          嚴(yán)重: Error filterStart
          2008-5-7 11:17:24 org.apache.catalina.core.StandardContext start
          嚴(yán)重: Context [/Struts2_Test] startup failed due to previous errors

          解決方法:
          刪除WebContent\WEB-INF\lib\struts2-spring-plugin-2.x.x.jar

          這樣啟動(dòng)就不會(huì)報(bào)錯(cuò)了  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2008-05-09 17:35 | miracle
          @小燕子
          創(chuàng)建工程的時(shí)候,選中show all wizards!  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-05-13 01:39 | tomate
          在我的環(huán)境下是因?yàn)?quot;struts2-jsf-plugin-2.0.11.1.jar"這個(gè)jar包引起的404問題.

          >關(guān)于第1次啟動(dòng)時(shí)就報(bào)HTTP404錯(cuò)的解決方法
          >錯(cuò)誤信息:
          >2008-5-7 11:17:24 org.apache.catalina.core.StandardContext start
          >嚴(yán)重: Error filterStart
          >2008-5-7 11:17:24 org.apache.catalina.core.StandardContext start
          >嚴(yán)重: Context [/Struts2_Test] startup failed due to previous errors

          >解決方法:
          >刪除WebContent\WEB-INF\lib\struts2-spring-plugin-2.x.x.jar   回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-05-13 13:58 | hover
          和我報(bào)的錯(cuò)一樣。不知道為什么,如果把里面的過濾器去掉就可以了,但這樣就失去了struts2.0的意義了。  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-05-15 14:14 | hover
          我覺得建立動(dòng)態(tài)的java工程(dynamic web project)不太方便,比如我每次修改完一點(diǎn)程序:.java,.xml,.jsp,.html之類的文件后,都必須得停止tomcat,重新打包發(fā)布應(yīng)用,再啟動(dòng)tomcat后才會(huì)看到修改后的頁面,否則的話顯示的還是以前的頁面或干脆找不著路徑,不知道各位有沒有遇見過這種情況。
          說明:動(dòng)態(tài)的應(yīng)用和普通的應(yīng)用都要求tomcat版本必須是5.5版本(含)以上的。
          剛開始用的5.1,怎么也不行,后來改成5.5就可以了,  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-05-16 22:03 | 迎風(fēng)十八刀
          受益非淺 以后常來逛逛  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2008-05-28 12:25 | 哈哈
          報(bào)404錯(cuò)誤的
          看一下web.xml中是index.jsp還是index.html
          <welcome-file-list>
          <welcome-file>index.jsp</welcome-file>
          </welcome-file-list>  回復(fù)  更多評(píng)論
            
          # re: 國際機(jī)票預(yù)定中心010-65946500 2008-05-29 17:16 | 李瑞
          北京華夏航空服務(wù)公司致力于從事國際、國內(nèi)特價(jià)機(jī)票、頭等公務(wù)特價(jià)、留學(xué)生機(jī)票、新移民機(jī)票、團(tuán)體特價(jià)機(jī)票代理業(yè)務(wù)等......
          常年為各大公司企事業(yè)單位免費(fèi)訂票,送票,成為我們的簽約客戶,享受最低折扣待遇!
          我們的服務(wù)理念:
          服務(wù)第一 !價(jià)位最低!重承諾!守信用!讓您足不出戶,就能享受最完善的服務(wù),最低廉的價(jià)格!
          公司網(wǎng)站:www.365piaowu.com www.1688jp.com www.v88jp.com www.beijingpiaowu.com
          訂票熱線:010-65946500 010-65921465
          24時(shí)熱線:13811004039 15001025358  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-05-29 23:56 | ake
          太感謝了。  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-06-03 15:49 | ysaas
          好文章!
          詳細(xì),易懂.
          本人就是加包的時(shí)候多加了些包,花了些時(shí)間排錯(cuò).其實(shí)不加入其它框架的情況,加截圖中的五個(gè)包就夠了,否則要加入其它框架的包  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-06-08 21:35 | jiangjkd
          第一個(gè)Struts 2.0應(yīng)用程序——Hello World
          運(yùn)行沒問題

          當(dāng)我在瀏覽器中
          鍵入http://localhost:8080/Struts2_HelloWorld/SayHello.jsp
          后臺(tái)報(bào)異常:
          org.xml.sax.SAXParseException: Element type "bean" must be declared.

          不知是什么原因

          我都弄了一下午都沒解決問題

          麻煩各位了

          怎么還沒解決呢,我也碰到了,搞不到,郁悶.........  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2008-06-10 15:06 | Lee
          為什么我按照你說的做,出現(xiàn)404錯(cuò)誤啊!  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-06-17 12:33 | WellBeing
          哎呀,今天搞了一個(gè)上午總算搞出來了,工程建了好幾遍,真不容易。

          說實(shí)話,已經(jīng)挺詳細(xì)了,8過,有些地方還是不太細(xì),也可能是Eclipse版本不同的緣故吧。另外,添加jar文件的那個(gè)地方,確實(shí)是不能Ctrl+A全選復(fù)制粘貼,就是因?yàn)檫@個(gè),一直是404錯(cuò)誤。

          后來,按照 臺(tái)風(fēng)過境 的做法,只添加這個(gè)幾個(gè)文件:
          ? struts2-core.jar
          ? xwork.jar
          ? ognl.jar
          ? freemarker.jar
          ? commons-logging.jar
          就搞定了

          我的環(huán)境是這樣的:
          Eclipse3.3
          Tomcat6.0.16
          Struts2.0.11.1

          希望對(duì)沒有成功的朋友有所幫助。  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-06-22 09:05 | Leyou
          受益匪淺啊

          用MyEclipse 6.5 的寫起來,應(yīng)該快多了……  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2008-06-27 10:26 | YY
          很好,很強(qiáng)大!  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-07-01 11:29 | everyman1978
          學(xué)習(xí)中,謝謝樓主。  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-07-08 22:22 | 邱瑞
          非常感謝。至于404問題,還是這位留言給解決的 非常感謝,同時(shí)也愿意在學(xué)習(xí)過程中將所學(xué)樂趣與大家分享
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2008-05-28 12:25 | 哈哈

          報(bào)404錯(cuò)誤的
          看一下web.xml中是index.jsp還是index.html
          <welcome-file-list>
          <welcome-file>index.jsp</welcome-file>
          </welcome-file-list>  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2008-07-10 18:07 | gg
          我照著做了,反復(fù)配置了許多遍,終于成功了!!!  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-07-23 20:27 | tinsoldier
          運(yùn)行這一頁的第二個(gè)例子,在Sayhello.jsp頁面點(diǎn)submit,每次都出現(xiàn)HTTP404錯(cuò)誤。
          描述:The requested resource (/Struts2_HelloWorld/HelloWorld) is not available.
          為什么啊?  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2008-07-26 10:08 | hfbupt
          我一開始也是404錯(cuò)誤,后來發(fā)現(xiàn)是自己把struts.xml放在了tutorial包里面,導(dǎo)致應(yīng)用找不到struts.xml中對(duì)應(yīng)的配置,所以出錯(cuò)。  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-07-28 11:59 | 獅子
          @WellBeing

          你那個(gè)是版本 不同了,肯定包少了
            回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-07-31 10:42 | 風(fēng)の稻草
          你們不覺得每次打成war包很麻煩嗎,還要重啟tomcat,不只這樣,我還有把tomcat/webapps下的項(xiàng)目文件夾刪掉。不知道誰有更快更好的方法。  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-08-13 14:15 | しゅうさん
          JDK 1.6.0_03
          Eclipse3.3
          Tomcat6.0.14
          不知道是為什么用Struts2.0.11.1報(bào)錯(cuò)
          而用Struts2.0.6可以  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-08-15 16:38 | krthur
          廣大報(bào)錯(cuò)404的朋友:
          sturts.xml這個(gè)配置文件一定要放在web-inf的classes目錄下,也就是你新建struts.xml文件是在src建的,而不是在web-inf下面建...
          困擾一下午的 resource not avalible終于好了....激動(dòng)....

            回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2008-08-27 17:45 | henry1451
          sturts.xml這個(gè)配置文件放在src目錄下就可以了,工程啟動(dòng)時(shí),會(huì)自動(dòng)拷貝到classes目錄下的.  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-09-02 11:45 | wangxiaoyu
          This release of Apache Tomcat was packaged to run on J2SE 5.0
          or later. It can be run on earlier JVMs by downloading and
          installing a compatibility package from the Apache Tomcat
          binary download page.
          機(jī)器上面裝了兩個(gè)jdk 一個(gè)1.4.7一個(gè)1.6.7!
          tomcat:5.0.23
          環(huán)境變量:配置的是1.6.7的
          各位大俠 怎么回是???  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-09-10 16:47 | dinner1984
          嚴(yán)重: Error filterStart
          2007-9-13 23:06:10 org.apache.catalina.core.StandardContext start
          嚴(yán)重: Context [/Struts2_HelloWorld] startup failed due to previous errors
          ====================
          我也出現(xiàn)這個(gè)問題,我是這么解決的,在lib文件夾里面僅僅包含五個(gè)基本包。其他的包都刪除了。
          這五個(gè)基本包是:commons-logging-1.0.4.jar,freemarker-2.3.8.jar,ognl-2.6.11.jar,struts2-core-2.0.10.jar,xwork-2.0.4.jar  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-09-22 18:24 | wangyh
          很不錯(cuò)  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-10-06 13:04 | scorpio215
          我用eclipse出現(xiàn)了一個(gè)問題
          我按照J(rèn)SP教程上的例子 安裝了j2sdk-1_4_2_06,,數(shù)據(jù)庫:MySQL 5 以及MySQL圖形化管理工具M(jìn)ySQL Administrator1.1.4 MySQL-Front V3.2
          開發(fā)工具eclipse以及相應(yīng)的Lomboz插件 WEB服務(wù)器Tomcat 5.0.16
          現(xiàn)在我新建WEB Dynamic Web Project 項(xiàng)目的時(shí)候 點(diǎn)NEXT 下面的窗口一直出不來 不知道是怎么一回事 請(qǐng)指點(diǎn)一下。。。謝謝   回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-10-06 13:05 | scorpio215
          如能解決 請(qǐng)加我QQ:232214995 或者發(fā)我郵件:scorpio215@126.com
          我將萬分感激  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-10-15 13:54 | asdf
          先下載比較新的jdk,別按教程上所說的,一般教程上說的版本都比較老了,eclipse上的所有插件先別裝,你先試下看能不能用,一步一步來配置環(huán)境  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2008-10-25 11:56 | 無名
          @風(fēng)の稻草
          把tomcat中的sevrver<Host> 修改一下
          <Host
          name="localhost"
          appBase="工程的具體位置(像:d:/workspace)\你的工程名字"
          unpackWARs="true"
          autoDeploy="true"
          xmlValidation="false"
          xmlNamespaceAware="false">
          <Context
          path="/"
          docBase="工程的具體位置(像:d:\\workspace)\\你的工程名字\\JspSource"
          reloadable="true">
          </Context>
          </Host>  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2008-11-08 18:36 | yang
          初學(xué)者可能要注意的一個(gè)問題是:struts.xml似乎只能放在src目錄下.一開始的時(shí)候我把這個(gè)文件放置在WEB-INF下和web.xml放在一起,結(jié)果第一個(gè)頁面sayHello.jsp出得來,提交給action時(shí)就出錯(cuò)了.后臺(tái)提示:警告: No configuration found for the specified action: 'HelloWorld' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
          IE那邊返回了一個(gè)404錯(cuò)誤頁面.把struts.xml移至src下,問題就解決了.  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-11-12 01:54 |
          折騰了一個(gè)晚上,剛搞定第二步驟
          提醒新手注意下面幾點(diǎn):

          1, 一個(gè)是博主 寫錯(cuò)了 應(yīng)該是 struts.xml 不是 sturts.xml
          2, 如果啟動(dòng)tomcat的時(shí)候發(fā)現(xiàn)錯(cuò)誤,有關(guān).class文件的版本號(hào)不對(duì),那么注意一下當(dāng)前eclipse的jdk,我用jdk1.6編譯出來的就有錯(cuò),用1.5才可以

            回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2008-12-01 14:53 | 上帝禁區(qū)
          @哎
          是的.哈哈.
          補(bǔ)充一點(diǎn).現(xiàn)在官網(wǎng)上找不到2.0.0了.所以要添加的lib有些不同.只要5個(gè)jar文件.
          注意樓豬的開發(fā)環(huán)境.
          還有就是run on server運(yùn)行不起來.不知道為什么.只能啟動(dòng)tomcat插件.就是那個(gè)小貓的圖標(biāo).設(shè)置war文件導(dǎo)出路徑也不行.只能每次刪了再一步步導(dǎo)出.麻煩.  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-01-24 14:30 | 小鼬
          好文章,謝謝老師指點(diǎn)!  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-02-03 18:20 | 流汗的牙齒
          # re: 為Struts 2.0做好準(zhǔn)備 2009-02-16 16:57 | Andy_long
          好文章啊~··  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2009-02-26 20:09 | jh
          # re: 為Struts 2.0做好準(zhǔn)備 2009-03-10 10:07 | 龍華城
          @流汗的牙齒

          你引入commons-fileupload-1.2.1.jar包再試試,新版本必須引入commons-fileupload-1.2.1.jar包.要不然就會(huì)出現(xiàn)404錯(cuò)誤.  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-03-11 20:32 | 2少
          老師,為什么我照你的步驟一步步地做.可是打包之后都不行啊.2個(gè)都是這樣.
          在IE上顯示的是
          type Status report

          message /Struts2_HelloWorld/

          description The requested resource (/Struts2_HelloWorld/) is not available.

          為什么啊?剛剛學(xué)struts2,什么都不懂.
            回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-03-20 10:22 | fanjj_023
          # re: 為Struts 2.0做好準(zhǔn)備 2008-09-10 16:47 | dinner1984

          嚴(yán)重: Error filterStart
          2007-9-13 23:06:10 org.apache.catalina.core.StandardContext start
          嚴(yán)重: Context [/Struts2_HelloWorld] startup failed due to previous errors
          ====================
          我也出現(xiàn)這個(gè)問題,我是這么解決的,在lib文件夾里面僅僅包含五個(gè)基本包。其他的包都刪除了。
          這五個(gè)基本包是:commons-logging-1.0.4.jar,freemarker-2.3.8.jar,ognl-2.6.11.jar,struts2-core-2.0.10.jar,xwork-2.0.4.jar 回復(fù) 更多評(píng)論  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-03-26 18:29 | cn
          嚴(yán)重: Could not find action or result
          There is no Action mapped for namespace / and action name HelloWorld. - [unknown location]
          at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
          at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
          at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:494) 我按照您這個(gè)步驟做的,提交就出這錯(cuò)。麻煩老師能幫我解決一下  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2009-03-27 20:33 | jackson
          There is no Action mapped for namespace / and action name HelloWorld.

          這是我的struts.xml
          <!DOCTYPE struts PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
          "http://struts.apache.org/dtds/struts-2.0.dtd">
          <struts>
          <include file="struts-default.xml"></include>
          <package name="tutorial" namespace="/" extends="struts-default.xml">
          <action name="HelloWorld" class="tutorial.HelloWorld" type="">
          <result>/HelloWorld.jsp</result>
          </action>
          </package>
          </struts>  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2009-03-31 11:42 | 張峰
          真的很好,希望樓主繼續(xù)努力,出更多精品
            回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-04-09 02:44 | hoist
          lz圖文并茂,講解和清晰又不累贅。同時(shí)對(duì)IDE的操作講解的很好,學(xué)到很多操作技巧。謝謝  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-04-24 14:09 |
          在“File name”中鍵入sturts.xml,點(diǎn)擊“Finish”,然后將struts.xml的內(nèi)容修改為:
          哥哥把struts.xml第一個(gè)寫成sturts.xml.大家注意下啊  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-04-24 17:19 | 謝謝max
          受益匪淺
          謝謝!

          還有,你很厲害。  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2009-04-28 16:04 | 無名
          very good  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-05-09 19:45 | aman
          太好了,收藏了!  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-05-14 17:21 | miaomiao
          need: commons-fileupload-1.2.1.jar  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-05-14 21:02 | aiwori
          謝謝 很詳細(xì)  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2009-05-27 22:08 | 木頭人
          是的,tomcat5.5以上才支持struts2.0
            回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-06-02 09:00 | ynyee
          @xiao
          少JAR包  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-06-26 09:02 | qqqiyv
          運(yùn)行struts2是要用tomcat6.0以上的  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-07-12 09:19 | jiyin
          我出現(xiàn)了unknown tag的錯(cuò)誤,是不是少了包?我沒裝struts2-extras.jar  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-08-07 15:24 | junchen
          @極度郁悶
          謝謝大哥的提醒!!!  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-08-24 11:47 | struts2
          錯(cuò)誤:警告: No configuration found for the specified action: 'HelloWorld' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
          2008-1-7 16:11:44 org.apache.struts2.components.Form evaluateExtraParamsServletRequest
          警告: No configuration found for the specified action: 'HelloWorld' in namespace: ''. Form action defaulting to 'action' attribute's literal value.

          整了2天,以為是namespace的問題.
          結(jié)果發(fā)現(xiàn)配置不成功的主要原因:

          1.在“File name”中鍵入sturts.xml,點(diǎn)擊“Finish”,然后將struts.xml的內(nèi)容修改為:



          這個(gè)里面 “sturts.xml”應(yīng)該改為:“ struts.xml”  回復(fù)  更多評(píng)論
            
          # 為什么不顯示標(biāo)簽呀 2009-08-29 15:53 | mao
          <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
          <%@ taglib prefix="s" uri="/struts-tags" %>

          <%
          String path = request.getContextPath();
          String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
          %>

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
          <html>
          <head>
          <base href="<%=basePath%>">

          <title>My JSP 'index.jsp' starting page</title>
          <meta http-equiv="pragma" content="no-cache">
          <meta http-equiv="cache-control" content="no-cache">
          <meta http-equiv="expires" content="0">
          <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
          <meta http-equiv="description" content="This is my page">
          <!--
          <link rel="stylesheet" type="text/css" href="styles.css">
          -->
          </head>

          <body>
          <s:text name="name"></s:text>
          </body>
          </html>
            回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-09-10 12:41 | 龍嘯天
          要是有視頻該有多好啊,我希望進(jìn)期內(nèi)能做出來一個(gè)Struts2的視頻,然后發(fā)給我,龍某萬分感謝,我的郵箱是:lx_610096108@163.com,或加我QQ也好:610096108,再次感謝!!!  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-09-14 23:38 | KoN
          @yuan29346
          <s:form theme="simple">
          </s:form>  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-10-30 11:14 | 路過
          我的環(huán)境:
          JDK : 1.5.0
          Tomcat : 5.5.27
          Eclipse : 3.4.2
          ★所有相關(guān)配置都和作者一樣
          關(guān)于第一步出現(xiàn)的404錯(cuò)誤(The requested resource (/Struts2_HelloWorld/) is not available)的原因
          ① 作者建立struts.xml文件的時(shí)候,文件名錯(cuò)誤 : sturts.xml→struts.xml
          ② 導(dǎo)入的核心JAR包應(yīng)該包含如下:
          commons-fileupload-1.2.1.jar
          commons-logging-1.0.4.jar
          freemarker-2.3.13.jar
          ognl-2.6.11.jar
          struts2-core-2.1.6.jar
          xwork-2.1.2.jar  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-10-30 11:43 | 路過
          關(guān)于第二部分,完全按照作者相關(guān)配置運(yùn)行,Junit順利通過,頁面表現(xiàn)正常。
          感謝作者分享,共同學(xué)習(xí)。  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-11-23 12:55 | tonydon
          不錯(cuò) 很值得學(xué)習(xí)下  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2009-12-16 16:16 | 123
          # re: 為Struts 2.0做好準(zhǔn)備 2009-12-17 12:46 | reddysheck
          請(qǐng)問樓主,按照上面說的順序進(jìn)行操作還需要配置tomcat和jdk的環(huán)境變量嗎?  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-12-17 12:51 | reddysheck
          再追加一個(gè)問題,關(guān)于第一部分的說明,我的第一個(gè)靜態(tài)頁面出不來,用tomcat運(yùn)行,畫面的提示錯(cuò)誤是:
          HTTP Status 404 - /Struts2.0/

          type Status report

          message /Struts2.0/

          description The requested resource (/Struts2.0/) is not available.

          Apache Tomcat/5.0.16

          這是什么原因啊?
          急需樓主幫忙!!  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-12-29 17:06 | ruanchao
          @路過
          對(duì)極了,多謝!  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-12-29 17:12 | ruanchao
          JDK 1.6.0_13
          Tomcat 5.5.28
          Eclipse eclipse-jee-galileo-SR1-win32.zip(based on Eclipse 3.5 SR1)

          我是java初學(xué)者, 歡迎一起學(xué)習(xí)探討  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2009-12-31 17:14 | 12
          12121212  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2010-01-08 11:11 | zzzzzzzzzzzzzzzzzzzzzzzzz
          @dinner1984
          zzzzzzzzzzzzzzz  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2010-01-25 11:39 | jj
          org.apache.jasper.JasperException: /login.jsp(30,2) The s:form tag declares that it accepts dynamic attributes but does not implement the required interface
          at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
          at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
          at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
          at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:777)
          at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1512)
          at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
          at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
          at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
          at org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
          at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
          at org.apache.jasper.compiler.Validator.validate(Validator.java:1739)
          at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:166)
          at org.apache.jasper.compiler.Compiler.compile(Compiler.java:315)
          at org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
          at org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
          at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
          at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
          at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
          at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter.doFilter(StrutsPrepareFilter.java:82)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter.doFilter(StrutsExecuteFilter.java:85)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter.doFilter(StrutsPrepareFilter.java:82)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at bw.sms.util.RequestFilter.doFilter(RequestFilter.java:45)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
          at java.lang.Thread.run(Thread.java:619)

          什么錯(cuò)誤?請(qǐng)教!  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2010-03-24 16:31 | 王小偉
          <s:form>
          應(yīng)該要改成
          <s:form action="HelloWorld.action">
          不然提交跳不了的。第一次嘗試struts2.
            回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2010-03-24 18:14 | kallyena
          @jj
          我也遇到過這類的問題。因?yàn)槲沂怯胑clipse galileo版本開發(fā)web項(xiàng)目。自己搭建環(huán)境,struts2和servlet進(jìn)行了解耦,所以我沒有把Tomcat下lib中的servlet-api.jar,el-api.jar和jsp-api.jar加進(jìn)去,后來寫個(gè)程序需要用到servlet,所以就把三個(gè)jar包加進(jìn)去了,問題出在了jsp-api.jar包上,可能與struts2中的一個(gè)jar包想沖突,刪除掉jsp-api.jar就好了。  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2010-05-20 11:15 | 老兵新傳
          謝謝!  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2010-05-26 22:37 | 大海

          首先感謝樓主,其次提出3個(gè)大家出現(xiàn)各種問題的原因:
          1、struts拼寫錯(cuò)誤;
          2、struts位置應(yīng)該在src目錄下
          3、struts中<result>/Hello.jsp</result>(請(qǐng)注意Hello.jsp前面的“/”)  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2010-07-06 16:04 | 賈武強(qiáng)

          <s:form action="HelloWorld"> 應(yīng)加上命名空間吧  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備[未登錄] 2010-08-26 16:54 | Angel
          # re: 為Struts 2.0做好準(zhǔn)備 2010-09-12 20:03 | 縮陰產(chǎn)品
          struts1跟struts2有啥區(qū)別啊?我看你寫的沒啥區(qū)別嗎?  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2010-09-26 15:01 | 風(fēng)里面
          @金立軍
          哥們 你那問題找到了嗎?  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2010-11-23 21:54 | ybkk
          看看lib包中有沒有
          javax.servlet.jsp.*之類的包,都刪除就可以。  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2010-12-02 14:36 | ares
          <s:form > 里面要加上name="myform"  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2011-01-05 17:47 | sqrhome
          哈哈,成功了,我的配置是tomcat6.0, jre6, 加上apps下的lib中的jar包五個(gè)。  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2011-04-07 14:43 | zhonghuazhi
          課程講解的很好 很詳細(xì)

          照著做 確實(shí) 實(shí)現(xiàn)了。 而且還配合有圖

          是很好的 謝謝分享。

            回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2011-06-01 11:13 | 地球乞丐
          很好 ,很完整,謝謝!  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2011-08-15 17:12 | yll
          正是我想學(xué)的,寫得太棒了。  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2011-10-06 14:04 | wsw
          good!perfect!  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2011-10-06 14:08 | wsw
          yes@wsw
          yes  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2012-11-11 00:44 | hanada
          真的很不錯(cuò)  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2014-03-26 18:18 | jxm
          一次性成功  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2015-10-16 11:55 | 暖暖的蟹
          @迎風(fēng)十八刀
          s@pakinsen
          404說明是你路徑有問題,還有可能是你JSP中某個(gè)標(biāo)簽不小心給刪了  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2015-10-16 13:57 | 暖暖的蟹
          @懶人
          Struts2與struts 1貌似很多地方不一樣,比1要好用  回復(fù)  更多評(píng)論
            
          # re: 為Struts 2.0做好準(zhǔn)備 2015-10-16 13:59 | 暖暖的蟹
          @哈哈
          明顯是jsp web項(xiàng)目里一般是不會(huì)出現(xiàn)html文件的  回復(fù)  更多評(píng)論
            
          評(píng)論共4頁: 1 2 3 4 下一頁 
          主站蜘蛛池模板: 新乐市| 夏邑县| 田东县| 武穴市| 清苑县| 天气| 册亨县| 金乡县| 达拉特旗| 邯郸市| 当阳市| 汽车| 扎兰屯市| 建宁县| 巴彦淖尔市| 临漳县| 科技| 杭锦后旗| 绥中县| 兴和县| 繁昌县| 土默特右旗| 黑河市| 镇原县| 黑水县| 通海县| 耒阳市| 承德市| 阜新| 文昌市| 牡丹江市| 河曲县| 陇川县| 孟州市| 根河市| 浦东新区| 文山县| 梨树县| 石城县| 宜良县| 西青区|