struts 2.0

<script type=text/javascript> // </script> <script src="/WebResource.axd?d=PyW-m2hLmppJ9byT1bYEqw2&t=633363616222850001" type=text/javascript></script> <script language=JavaScript> function ctlent(evt,id) { if(evt.ctrlKey && evt.keyCode == 13) { try { TempSave(id); } catch(ex) { } finally { __doPostBack('AjaxHolder$PostComment$btnSubmit','') } } }</script> <script language=JavaScript>function SetReplyAuhor(author){document.getElementById('AjaxHolder_PostComment_tbComment').value+="@"+author+"/n";document.getElementById('AjaxHolder_PostComment_tbComment').focus();return false}</script> <script src="/ScriptResource.axd?d=Io4r5Qx-zmHVyf9RpZLpA94PR0yylGVrHR75KduCbtx9Wbjv2jQEzXmeH0no0z7nxVOXJo-onw_3WI2pcwKr3w2&t=633363616222850001" type=text/javascript></script> <script src="/ScriptResource.axd?d=Io4r5Qx-zmHysvkgwLW9yk7rUGj5M-geQRTOmI9WMPaWNcTLoZx7IpNZpIR4LFVQ0&t=633065726440000000" type=text/javascript></script> <script src="/ScriptResource.axd?d=Io4r5Qx-zmHysvkgwLW9yk7rUGj5M-geQRTOmI9WMPaVSfXvXlH0xWaTv3M_TRDPzVKh75E08VU1&t=633065726440000000" type=text/javascript></script> <script type=text/javascript> // </script>
随笔-21  评论-1508  文章-0  trackbacks-0

Struts作为MVC 2的Web框架,自推出以来不断受到开发者的追捧,得到用广泛的应用。作为最成功的Web框架,Struts自然拥有众多的优点:

  • MVC 2模型的使用
  • 功能齐全的标志库(Tag Library)
  • 开放源代码

但是,所谓“金无赤金,人无完人”,Struts自身也有不少的缺点:

  • 需要编写的代码过多,容易引起“类爆炸”
  • 单元测试困难

这些缺点随着Web的发展越来越明显。这就促生了Struts 2.0,它的诞生能很好的解决上述问题。 好啦,废话就不多说了,现在就让我们感受一下的Struts 2.0的魅力吧。

  1. 搭建开发和运行环境
    1. 到Apache下载Struts 2.0包

    2. 打开Eclipse 3.2新建Web工程

      点击菜单File/New/Project,出现如图1所示对话框
      图1 新建工程对话框
      图1 新建工程对话框
      选择Web/Dynamic Web Project,点击“Next”,出现图2对话框

      图2 新建动态Web工程对话框
      图2 新建动态Web工程对话框
      在“Project Name”中键入Struts2_HelloWorld,点击“New”,出现以下对话框

      图3 新建服务器运行时对话框
      图3 新建服务器运行时对话框
      选择“Apache/Apache Tomat v5.5”,点击“Next”,出现以下对话框

      图4新建服务器运行时对话框
      图4新建服务器运行时对话框
      点击“Finish”,关闭对话框。

    3. 将Struts 2.0 lib下的jar文件加到工程的构建路径(build path)

      图5 Struts 2.0的lib目录
      图5 Struts 2.0的lib目录
      按ctr+a全选,复制,再转到Eclipse窗口,在“Project Explorer”子窗口中选中Struts2_HelloWorld/WebContent/WEB-INF/lib,然后粘贴。经过Eclipse自动刷新“Project Explorer”子窗口,刚才所粘贴的jar文件应该会出现在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文件

      右键点击,Struts2_HelloWorld/Java Resources: src,出现如图7所示菜单
      图7 新建Other菜单
      图7 新建Other菜单
      点击“Other”,出现新建对话框,如图8所示

      图8 新建对话框
      图8 新建对话框
      点击“Next”,出现新建文件对话框,如图9所示

      图9 新建文件对话框
      图9 新建文件对话框
      在“File name”中键入sturts.xml,点击“Finish”,然后将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" />
      </ struts >

    6. 新建index.html文件

      右键点击Struts2_HelloWorld/WebContent,出现如图10所示的菜单
      图10 新建Other菜单
      图10 新建Other菜单
      点击“Other”,出现新建对话框,如图11所示

      图11 新建对话框
      图11 新建对话框
      选择Web/HTML,点击“Next”出现如图12所示的对话框

      图12 新建HTML页面对话框
      图12 新建HTML页面对话框
      在“File Name”中键入index.html,点击“Next”,出现如图13所示的对话框

      图13 模板选择对话框
      图13 模板选择对话框
      点击“Finish”,将index.html的内容修改为以下内容:

      <! 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. 将应用程序打包到tomcat上

      右键点击Struts_HelloWorld,出现如图14所示的菜单
      图14 工程菜单
      图14 工程菜单
      点击“Export/WAR file”,出现如图15所示的对话框

      图15 输出对话框
      图15 输出对话框
      选择“Web/WAR file”,点击“Next”,出现如图16所示的对话框

      图16 输出路径对话框
      图16 输出路径对话框
      输入war文件的路径(如%tomcat%/webapps/Struts2_HelloWorld.war),点击“Finish”关闭对话框。

    8. 启动tomcat,运行应用程序

      打开你的Internet Explorer,键入http://localhost:8080/Struts2_HelloWorld/,窗口输出如图17所示
      图17 Hello World窗口
      图17 Hello World窗口

  2. 第一个Struts 2.0应用程序——Hello World
    1. 新建类包(package)

      右键点击Struts2_HelloWorld/Java Resources: src,出现如图18所示菜单
      图18 新建菜单
      图18 新建菜单"
      点击“New/Package”,出现如图19所示对话框

      图19新建Java类包对话框
      图19新建Java类包对话框
      在“Name”键入tutorial,点击“Finish”关闭对话框。

    2. 新建HelloWorld.java文件

      右键点击Struts2_HelloWorld/Java Resources: src/tutorial,出现如图20所示菜单
      图20 新建菜单
      图20 新建菜单
      点击“New/Class”,出现如图21所示对话框

      图21 新建Java类对话框
      图21 新建Java类对话框
      在“Name”中键入HelloWorld,在“Superclass”中键入com.opensymphony.xwork2.ActionSupport,点击“Finish”关闭对话框。将HelloWorld.java的内容修改为:

      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所示对话框
      图22 新建对话框
      图22 新建对话框
      点击“Next”, 进入下一步,如图23所示

      图23 新建JSP对话框
      图23 新建JSP对话框
      在“File name”键入SayHello.jsp,点击“Next”进入下一步,如图24所示

      图24 模板选择对话框
      图24 模板选择对话框
      点击“Finish”关闭对话框,并将SayHello.jsp的内容修改为:

      <% @ 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(请参考上一步),HelloWorld.jsp的内容为:
      <% @ 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. 重新打包发布应用程序

      先停止tomcat, 再将tomcat里webapps下的Struts2_HelloWorld.war和Struts2_HelloWorld文件夹删除,参照“将应用程序打包到tomcat上”重新发布应用程序。

    7. 启动tomcat,运行测试

      打开Internet Explorer,键入http://localhost:8080/Struts2_HelloWorld/SayHello.jsp,窗口输出如图25所示
      图25 SayHello.jsp
      图25 SayHello.jsp
      在“Name”键入字符串(如World),点击Submit,转到HelloWorld.jsp页面,如图26所示

      图26 HelloWorld.jsp
      图26 HelloWorld.jsp

  3. 单元测试Hello World

    在文章开始的时候提及,单元测试困难是Struts一大缺点。现在让我们在体验一下,在Struts 2.0中是如何进行测试的。

    1. 新建JUnit单元测试

      右键点击Struts2_HelloWorld/Java Resources: src/tutorial,弹出如图27所示对话框
      图27 新建菜单
      图27 新建菜单
      点击“Next/Other”

      图28 新建对话框
      图28 新建对话框
      选择“Java/JUnit/JUnit Test Case”,点击“Next”

      图29 新建JUnit 测试用例对话框
      图29 新建JUnit 测试用例对话框
      选择“New JUnit 4 test”,在“Name”中键入HelloWorldTest,在“Class under test”键入tutorial.HelloWorld,点击“Next”

      图30 选择方法对话框
      图30 选择方法对话框
      选中HelloWorld/execute方法,点击Finish。如果生成的HelloWorldTest.java文件的图标(Icon)出现红色交叉标志,请进行以下步骤添加JUnit 4的jar包。

      右键点击Struts2_HelloWorld,出现如图所示菜单。 图31 新建菜单
      图31 新建菜单
      点击“Build Path/Add Libararis”,弹出图32对话框

      图32 添加库对话框
      图32 添加库对话框
      选中“JUnit”,点击“Next”

      图33 选择版本对话框
      图33 选择版本对话框
      选择“JUnit 4”,点击“Finish”关闭对话框,并将HelloWorldTest.java的内容修改为:

      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. 运行单元测试

      右键点击Struts2_HelloWorld/Java Resources: src/tutorial/HelloWorldTest.java,弹出如图34所示菜单
      图34 运行为菜单
      图34 运行为菜单
      点击“Run As/JUnit Test”,出现JUnit子窗口如图35所示

      图35 JUnit子窗口
      图35 JUnit子窗口
      图35的绿色矩形表示,所有单元测试通过。

  4. 总结

    上面的例子简单地演示了,Web 应用程序的基本操作,也即是,页面输入->Action处理->再输出到另外页面。Struts 2.0的简单易用、方便测试相信也会给大家留下不错的印象吧。我相信,Struts 2.0作为一个全新的Web架构,将会再次掀起Web开发的热潮。 不过,Struts 2.0还在测试中,正式版的发布还需些时日,所以文档方面可能有所欠缺。请大家继续留意我的博客,我会尽我所能为大家写更多关于Struts 2.0的文章。

posted on 2006-10-10 18:35 Max 阅读(61000) 评论(284)   编辑   收藏 所属分类: Struts 2.0系列
<script type=text/javascript> // </script>
评论共3页: 1  2  3  下一页 

评论:
#  re: 为Struts 2.0做好准备 2007-09-13 09:42 | ttl_web (ttl_web@yahoo.com.cn)
谢谢!

通过您的这篇文章,使我对struts2 doc中“ http://struts.apache.org/2.x/docs/hello-world.html”有了实际的认识

再次感谢!!   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-09-13 23:14 | xun
请问下面的问题怎么解决??

严重: Exception starting filter struts2
Error loading configuration file struts-default.xml - Class: com.opensymphony.xwork2.config.providers.XmlConfigurationProvider
File: XmlConfigurationProvider.java
Method: loadConfigurationFiles
Line: 850 - com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java:850:-1
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:135)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:100)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:130)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3693)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1023)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1015)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:582)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.NullPointerException
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:850)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:131)
... 33 more
2007-9-13 23:06:10 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2007-9-13 23:06:10 org.apache.catalina.core.StandardContext start
严重: Context [/Struts2_HelloWorld] startup failed due to previous errors
2007-9-13 23:06:11 org.apache.coyote.http11.Http11Protocol start   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2007-09-16 09:21 | Jimmy
请问是不是要tomcat5.5以上的啊?

我的tomcat5.0.16+jdk1.42+struts2.10老是报错

Status report

message /Struts2_HelloWorld/

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

   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-09-18 15:29 | @ctan
郁闷,我的报这个错 /
myeclipse5.0 tomcat5.0 jdk1.4.2

信息: validateJarFile(C:/java_dev/Tomcat 5.0/webapps/Struts2App/WEB-INF/lib/servlet-api-2.4.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
2007-9-18 15:19:25 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2007-9-18 15:19:25 org.apache.catalina.core.StandardContext start
严重: Context startup failed due to previous errors
2007-9-18 15:19:25 org.apache.catalina.core.StandardHostDeployer install
信息: Installing web application at context path /tomcat-docs from URL file:C:/java_dev/Tomcat 5.0/webapps/tomcat-docs

谢谢各位老大。   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2007-09-20 11:14 | 台风过境
严重: Exception starting filter struts2
Unable to load bean: type:com.opensymphony.xwork2.ObjectFactory class:org.apache.struts2.spring.StrutsSpringObjectFactory - bean - jar:file:/F:/JavaProjects/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/Struts2_HelloWorld/WEB-INF/lib/struts2-spring-plugin-2.0.9.jar!/struts-plugin.xml:8:132
……
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware
……
严重: Error filterStart
2007-9-20 11:01:46 org.apache.catalina.core.StandardContext start
严重: Context [/Struts2_HelloWorld] startup failed due to previous errors
2007-9-20 11:01:51 com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register
信息: Parsing configuration file [struts-default.xml]
2007-9-20 11:01:53 com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register
信息: Parsing configuration file [struts-plugin.xml]
2007-9-20 11:01:53 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
按照Max说的方法还是不能解决奥,前面出现这个问题的朋友不知道怎么解决的?   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2007-09-20 15:32 | 台风过境
Unable to load bean: type:com.opensymphony.xwork2.ObjectFactory
这个tomcat启动错误已经解决,楼主的例子顺利通过了,嘿嘿!

我之前是把struts-2.0.9-lib中的所有jar包都放到WEB-INF/lib中,才出现上面那个错误,后来把lib中的包删除,只保留
• struts2-core.jar
• xwork.jar
• ognl.jar
• freemarker.jar
• commons-logging.jar
就顺利通过了,看来把所有的包都导入,未必是件可取的事情啊!
   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2007-09-20 16:31 | 台风过境
打好war包后,启动tomcat服务器的时候,有警告信息:Could not parse struts.local setting,substituting default VM local,不知道怎么回事,我在eclipse下启动tomcat运行是没问题的!   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2007-09-21 13:26 | Jimmy
javax.servlet.ServletException: Filter execution threw an exception


root cause

java.lang.Error: Unresolved compilation problem:
The public type HelloWorld must be defined in its own file

tutorial.HelloWorld.<init>(Helloworld.java:5)

   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-09-26 08:21 | 小燕子
请问一下老师,我的eclipse3.2中装了myeclipse5.1.1为什么没有创建dynamic web project工程的地方呢   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-09-26 14:42 | 小学生
老师您好:
我照着这个样子做了一下,现在已经能运行起来了,但是,就是在eclipse中总是报这个错:
The value [HelloWorld] for attribute [action] in tag [form] is not valid.
报错的位置是SayHello.jsp中的第9行:<s:form action="HelloWorld">,请问,这是什么原因呢?

另外,您说的“
按ctr +a全选,复制,再转到Eclipse窗口,在“Project Explorer”子窗口中选中Struts2_HelloWorld/WebContent/WEB-INF/lib,然后粘贴。

的这一句话,我实在不知道如何操作,因为,当我在“Project Explorer”子窗口中选中Struts2_HelloWorld/WebContent/WEB-INF/lib的时候,paste选择项是灰色的,因此,我只好将这些jar文件直接文件拷贝到了lib目录下,但是,就是在project explorer中的Struts2_HelloWorld/Java Resources: src/Libraries/Web App Libraries下看不到这些jar文件。尽管如此,却又不影响打包和运行;)

我现在确实不知道我在哪里出错了,希望老师同学指点一下,谢谢!!!

   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-09-26 15:01 | 小学生
老师您好:
现在直接文件拷贝到了lib目录下的jar文件能在project explorer中的Struts2_HelloWorld/Java Resources: src/Libraries/Web App Libraries下看到了!!!不好意思,刚才耐心不够~~ :P

但是,SayHello.jsp中的第9行:<s:form action="HelloWorld">,依然会引起eclipse报:The value [HelloWorld] for attribute [action] in tag [form] is not valid.的错误。答案期待中......



   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-09-27 16:57 | T
有没有谁搞好了的,提供给我一个让我看看,我搞的老是出错。
如方便发到邮箱里22211369(at)qq.com   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-10-09 11:16 | 88
严重: Exception starting filter struts2
Unable to load bean: type:com.opensymphony.xwork2.ObjectFactory class:org.apache.struts2.spring.StrutsSpringObjectFactory - bean - jar:file:/D:/mytools/apache-tomcat-5.5.23/webapps/Struts2_HelloWorld/WEB-INF/lib/struts2-spring-plugin-2.0.9.jar!/struts-plugin.xml:8:132
严重: Error filterStart
2007-10-9 10:59:28 org.apache.catalina.core.StandardContext start
严重: Context [/Struts2_HelloWorld] startup failed due to previous errors
2007-10-9 10:59:29 org.apache.coyote.http11.Http11BaseProtocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2007-10-9 10:59:29 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2007-10-9 10:59:30 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/141 config=null
2007-10-9 10:59:30 org.apache.catalina.storeconfig.StoreLoader load
信息: Find registry server-registry.xml at classpath resource
2007-10-9 10:59:30 org.apache.catalina.startup.Catalina start
信息: Server startup in 41750 ms   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-10-11 16:25 | 金立军
请教一下我在调式这第段代码:
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<title>Struts 2 Cool Tags - &lt;s:doubeselect/ &gt;</title>
<s:head />
</head>
<body>
<h2>&lt;s:doubleselect/&gt;</h2>
<s:form action="Store" >
<s:set name="foobar"
value="#{'Java': {'Spring', 'Hibernate', 'Struts 2'}, '.Net': {'Linq', ' ASP.NET 2.0'}, 'Database': {'Oracle', 'SQL Server', 'DB2', 'MySQL'}}" />
<s:doubleselect list="#foobar.keySet()"
doubleName="technology"
doubleList="#foobar[top]"
label="Technology" />
</s:form>
</body>
</html>



一运行就出现这下面这个错误:


FreeMarker template error!

Expression parameters.formName is undefined on line 76, column 43 in template/simple/doubleselect.ftl.
The problematic instruction:
----------
==> ${parameters.formName} [on line 76, column 41 in template/simple/doubleselect.ftl]
in include "/${parameters.templateDir}/simple/doubleselect.ftl" [on line 3, column 1 in template/xhtml/doubleselect.ftl]
----------

Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Expression parameters.formName is undefined on line 76, column 43 in template/simple/doubleselect.ftl.
at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
at freemarker.core.Expression.getStringValue(Expression.java:118)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.Environment.include(Environment.java:1375)
at freemarker.core.Include.accept(Include.java:155)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:196)
at freemarker.core.Environment.process(Environment.java:176)
at freemarker.template.Template.process(Template.java:232)
at org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:148)
at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:530)
at org.apache.struts2.components.UIBean.end(UIBean.java:484)
at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43)
at org.apache.jsp.index_jsp._jspx_meth_s_doubleselect_0(index_jsp.java:185)
at org.apache.jsp.index_jsp._jspx_meth_s_form_0(index_jsp.java:133)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:76)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
请问一下各位是什么原因呀
学生在此谢过了
   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2007-10-19 15:07 | zero
java.lang.NoSuchMethodError: javax.xml.transform.dom.DOMResult.getNextSibling()Lorg/w3c/dom/Node;
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getOutputHandler(TransformerImpl.java:390)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerHandlerImpl.setResult(TransformerHandlerImpl.java:137)
at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.setup(DomHelper.java:213)
at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:198)
at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:189)
at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:175)
at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:115)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:830)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:131)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:100)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:130)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:225)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:308)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:79)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3676)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4327)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:683)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:432)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:964)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:476)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2298)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)

我在测试上面的例子的时候,发生了上面的错误   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2007-10-19 15:50 | zero
是jdk版本的原因,如果使用jdk1.4会报错但是使用jdk1.6就会报上面的这个错误,使用jdk1.5就正常了。   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-10-24 12:44 | 信鸽
学到了   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-10-31 09:46 | heiyechouke
nice, thanks very much!   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2007-10-31 13:55 | 菜鸟
我的eclipse中为什么不能创建dynamic web project呢?

   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-11-03 15:32 | 帅哥
只想说一个字,“日”!   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-11-08 10:34 | 猛男
谢谢您给我介绍这么漂亮的“妞子”,用起来真爽!   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-11-11 08:40 | skycliff
楼主幸苦了,期待更多更好的文章。   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-11-16 11:45 | maszxy
@就
好象不对呀,中文还是显示乱码

我的QQ:531877631   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-11-16 12:14 | maszxy
@Mike
因为你在struts.xml里给这个action定的名字是HelloWorld   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-11-16 12:23 | cricy
都要发布才能测试吗?有没有可以直接测试的?   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-11-16 16:43 | onlykwx
写得很好,支持一下!   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-11-23 11:36 | gongbing
请问,您最后发布应用程序的时候采用的是打包成war文件到tomcat里,但是如果这样的话,好像每修改一次程序就要把先前的war文件删除掉,重新打包,这样做卫冕太麻烦了,请问有没有其他的简单一点的办法?谢谢   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-11-24 17:09 | sandbox
郁闷,怎么调都调试不通 ,提交表单后就是404错误,也不知道什么原因 望赐教

另外 感觉的文章很好,能否告诉一下出处
email:flywyvern@126.com 同时希望发一份这篇文章的测试源码,不用带包,我就不信调不通
最后 谢谢:)   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-11-28 16:36 | xiao
第一个Struts 2.0应用程序——Hello World
运行没问题

当我在浏览器中
键入 http://localhost:8080/Struts2_HelloWorld/SayHello.jsp
后台报异常:
org.xml.sax.SAXParseException: Element type "bean" must be declared.

不知是什么原因

我都弄了一下午都没解决问题

麻烦各位了


   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-11-30 13:52 | 不能说
是不是Tomcat5.0不能跑Struts2.0啊???   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-12-08 18:25 |
非常好!~   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-12-08 18:26 |
ddd   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-12-08 18:27 |
@月
ddd   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-12-18 14:16 | windylovesandy
我的出错,以下错误是怎么回事?
我不知道struts-tags.jar在哪来?我在lib中没有找到,应该放在哪里。希望指教以下
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: File "/struts-tags" not found
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:50)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:114)
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:159)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:423)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:146)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-12-20 11:40 | 阿祥
比较好!讲得比较细!thanks (the team)   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-12-20 17:19 |
有问题说出来   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-12-29 00:38 | 凌晨风
2007-12-29 0:24:48 org.apache.struts2.components.Form evaluateExtraParamsServletRequest
警告: No configuration found for the specified action: 'login.action' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
2007-12-29 0:24:48 org.apache.struts2.components.Form evaluateExtraParamsServletRequest
警告: No configuration found for the specified action: 'login.action' in namespace: ''. Form action defaulting to 'action' attribute's literal value.

出现如下错误,程序运行正常!不知道只是怎么回事?
错误发生在login.jsp页面刷新时就出现。   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2007-12-30 16:28 | xx
做个视频多方便,这样一张一张的截图很麻烦   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2008-01-01 18:12 | aa
@新手
写action的名字   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-01-07 17:20 | C++
警告: 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个星期了,晕死了!   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-01-08 15:34 | 自由化xl
挺不错的, 谢谢楼主的细心总结!   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-01-11 23:16 | bizairshop
很好的例子
北京机票推荐 http://www.newskyair.com   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-01-18 14:12 | tt
@C++
表单提交的 action name 和 struts.xml 的 action name 是否相同   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-01-20 14:04 | 陈龙
是个好文章   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-01-23 16:27 | 漂泊
警告: No configuration found for the specified action: 'HelloWorld' in namespace
: ''. Form action defaulting to 'action' attribute's literal value.
2008-1-23 16:21:56 org.apache.struts2.components.Form evaluateExtraParamsServlet
Request
警告: No configuration found for the specified action: 'HelloWorld' in namespace
: ''. Form action defaulting to 'action' attribute's literal value.

什麽原因?

   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-01-23 17:04 | C++
@tt
我的代码全是照着复制、粘贴的,不会有错,我也反复检查过N!遍。郁闷。谢谢tt大侠了   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-01-24 17:16 |
junit.framework.AssertionFailedError: /WEB-INF/web.xmlが見つかりません
at servletunit.struts.MockStrutsTestCase.getActionServlet(MockStrutsTestCase.java:344)
at servletunit.struts.MockStrutsTestCase.tearDown(MockStrutsTestCase.java:130)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

我用MockStrutsTestCase框架做的一个简单测试,哪位老兄帮忙看看是什么问题啊?

   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-01-27 13:38 | jinruihua
@zero
可能是你的.jsp页面的action名与struts中的action不一致导致。
maybe help.   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-01-28 16:38 |
是一致的,被测试的代码都是成品了,应该不是代码的问题   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-02-17 18:46 | 111
@jarwang
那是因为你的表单的编码还是ISO8859-1。   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-02-21 14:23 | laibin
谢谢!   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-02-22 09:12 | GG_wg
例子不错,我测试中文提交也没有问题(firefox)   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2008-02-22 17:10 | lee
提交表单后显示下如错误:
警告: No configuration found for the specified action: 'HelloWorld' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
2008-2-22 17:08:55 org.apache.struts2.components.Form evaluateExtraParamsServletRequest   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-03-10 11:35 | yuan29346
多谢!
我是在JBuider上工作的,按照你的提示,呵呵,顺利搞定到JB中了。
现在刚准备学这个struts2,现在有很多疑问啊!很郁闷,我们公司不用这个。
比如:
<s:form action="Login">
<s:text name="username"/><s:textfield key="username"/>
<s:text name="password"/><s:password key="password" />
<s:submit/>
</s:form>
这个会自动输出table,和我想要的不一样!我相知道怎么样才能控制输出的HTML标签?
   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-03-13 16:45 | zhengtu
太牛了;
照做了;
没问题;
讲的很细;
谢谢.   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-03-18 09:20 | 小魏
照做的,完全正确,在这个过程中遇到许多问题,解决之后发现自己学习到很多:)
谢谢:)   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-03-18 12:33 | 木风口子
我第一次运行HelloWorld没有问题,但后来又不行了,一直报错:
HTTP Status 404 - /projects/struts/Struts2_HelloWorld

--------------------------------------------------------------------------------

type Status report

message /projects/struts/Struts2_HelloWorld

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

导出的WAR文件在ROOT/projects/struts/下
本机配置:
jdk1.5,
eclipse为最新europe
tomcat5.0.30
没有加载包,因为我已经有lomboz struts包
不会是没加包的原因,
请赐教!多谢!   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-03-25 17:21 | visitor
@凌晨风
也困绕我半天。。。
后来照另外的教程做出一个可以跑的,再Beyond compare比较一下,发现是建立struts.xml时错了,名字不对,浪费好几个小时   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2008-03-25 22:37 | 绿茶
你好..谢谢..我觉得就是tomcat最好是5.x或6.X..JDK1.5以上吧..我刚开始也是按你说的那样去测试..在以前的版本上测试..都不行..后来下了个新版..就可以了..还是就是...struts.xml一定要放在classess目录下...   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-03-28 20:01 | pakinsen
我按照你的方法做了,第一部分是成功的,但是第二步添加了那几个JSP文件后,一打开TOMCAT就说找不到SayHello.jsp。这是为什么呢?我反复看了你的文章,没有地方不一致啊。   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-04-07 10:39 | 小新手
我用的是myeclipse5.0 tomcat5.5 struts2.0.11.1的包,按照上面的步骤连第一部分都不能正常运行,如果不按照上面步骤修改web.xml内容的话第一步反而能实现,但第二部分仍然不能实现,为什么呢。。。。   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-04-14 19:04 | 极度郁闷
按照步骤配置了,但SayHello.jsp提交失败,后台总是报错“no configuration found for the specified action...”,试了无数次,google了半天,还是不行,最后终于极度郁闷的发现,配置文件名称是“sturts.xml”,这个名称是从你文章里拷过去的,有一个字母顺序错了,狂晕!!!浪费了近3个小时,555555555555555.............   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2008-04-21 18:00 | lf
以前一直都用的struts1.X, 学习下!
设置一切OK,绿色顺利出来
不错,支持   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-04-21 20:49 | sidekick
No configuration found for the specified action: 'HelloWorld' in namespace

是因為 copy 'sturts.xml' 的結果, 請更正文章中 sturts.xml 為 struts.xml

sturts.xml --> struts.xml   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-04-23 17:15 | 懒人
和1.0差在哪?不能出了新技术就什么地方都用吧?   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-04-29 17:26 | snowwolf76
写得太棒了。
我用的struts-2.0.11.1+jdk1.6.0_05+tomcat 5.5.26.
关于404的错误,我是先把所有struts2的jar文件粘贴到lib目录下,然后把struts2-spring-plugin-2.xxx.jar,
struts2-plexus-plugin-2.xxx.jar,
struts2-jsf-plugin-2.xxx.jar删除,
还对照截图删除了antlr-2xxx.jar, commons开头的几个jar(也许不是他们的原因),因为我是在eclipse里面debug工程看到了些异常。   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-04-30 11:44 | goldgood
在此页面中的,java源程序的树形结构,是如何实行的?   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-05-04 14:30 | goldgood
问题解决。   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-05-07 11:26 | 传说中的???
关于第1次启动时就报HTTP404错的解决方法
错误信息:
2008-5-7 11:17:24 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2008-5-7 11:17:24 org.apache.catalina.core.StandardContext start
严重: Context [/Struts2_Test] startup failed due to previous errors

解决方法:
删除WebContent/WEB-INF/lib/struts2-spring-plugin-2.x.x.jar

这样启动就不会报错了   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2008-05-09 17:35 | miracle
@小燕子
创建工程的时候,选中show all wizards!   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-05-13 01:39 | tomate
在我的环境下是因为"struts2-jsf-plugin-2.0.11.1.jar"这个jar包引起的404问题.

>关于第1次启动时就报HTTP404错的解决方法
>错误信息:
>2008-5-7 11:17:24 org.apache.catalina.core.StandardContext start
>严重: Error filterStart
>2008-5-7 11:17:24 org.apache.catalina.core.StandardContext start
>严重: Context [/Struts2_Test] startup failed due to previous errors

>解决方法:
>删除WebContent/WEB-INF/lib/struts2-spring-plugin-2.x.x.jar    回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-05-13 13:58 | hover
和我报的错一样。不知道为什么,如果把里面的过滤器去掉就可以了,但这样就失去了struts2.0的意义了。   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-05-15 14:14 | hover
我觉得建立动态的java工程(dynamic web project)不太方便,比如我每次修改完一点程序:.java,.xml,.jsp,.html之类的文件后,都必须得停止tomcat,重新打包发布应用,再启动tomcat后才会看到修改后的页面,否则的话显示的还是以前的页面或干脆找不着路径,不知道各位有没有遇见过这种情况。
说明:动态的应用和普通的应用都要求tomcat版本必须是5.5版本(含)以上的。
刚开始用的5.1,怎么也不行,后来改成5.5就可以了,   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-05-16 22:03 | 迎风十八刀
受益非浅 以后常来逛逛   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2008-05-28 12:25 | 哈哈
报404错误的
看一下web.xml中是index.jsp还是index.html
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>   回复   更多评论
  
#  re: 国际机票预定中心010-65946500 2008-05-29 17:16 | 李瑞
北京华夏航空服务公司致力于从事国际、国内特价机票、头等公务特价、留学生机票、新移民机票、团体特价机票代理业务等......
常年为各大公司企事业单位免费订票,送票,成为我们的签约客户,享受最低折扣待遇!
我们的服务理念:
服务第一 !价位最低!重承诺!守信用!让您足不出户,就能享受最完善的服务,最低廉的价格!
公司网站:www.365piaowu.com www.1688jp.com www.v88jp.com www.beijingpiaowu.com
订票热线:010-65946500 010-65921465
24时热线:13811004039 15001025358   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-05-29 23:56 | ake
太感谢了。   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-06-03 15:49 | ysaas
好文章!
详细,易懂.
本人就是加包的时候多加了些包,花了些时间排错.其实不加入其它框架的情况,加截图中的五个包就够了,否则要加入其它框架的包   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-06-08 21:35 | jiangjkd
第一个Struts 2.0应用程序——Hello World
运行没问题

当我在浏览器中
键入 http://localhost:8080/Struts2_HelloWorld/SayHello.jsp
后台报异常:
org.xml.sax.SAXParseException: Element type "bean" must be declared.

不知是什么原因

我都弄了一下午都没解决问题

麻烦各位了

怎么还没解决呢,我也碰到了,搞不到,郁闷.........   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2008-06-10 15:06 | Lee
为什么我按照你说的做,出现404错误啊!   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-06-17 12:33 | WellBeing
哎呀,今天搞了一个上午总算搞出来了,工程建了好几遍,真不容易。

说实话,已经挺详细了,8过,有些地方还是不太细,也可能是Eclipse版本不同的缘故吧。另外,添加jar文件的那个地方,确实是不能Ctrl+A全选复制粘贴,就是因为这个,一直是404错误。

后来,按照 台风过境 的做法,只添加这个几个文件:
• struts2-core.jar
• xwork.jar
• ognl.jar
• freemarker.jar
• commons-logging.jar
就搞定了

我的环境是这样的:
Eclipse3.3
Tomcat6.0.16
Struts2.0.11.1

希望对没有成功的朋友有所帮助。   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-06-22 09:05 | Leyou
受益匪浅啊

用MyEclipse 6.5 的写起来,应该快多了……   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2008-06-27 10:26 | YY
很好,很强大!   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-07-01 11:29 | everyman1978
学习中,谢谢楼主。   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-07-08 22:22 | 邱瑞
非常感谢。至于404问题,还是这位留言给解决的 非常感谢,同时也愿意在学习过程中将所学乐趣与大家分享
# re: 为Struts 2.0做好准备[未登录] 2008-05-28 12:25 | 哈哈

报404错误的
看一下web.xml中是index.jsp还是index.html
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2008-07-10 18:07 | gg
我照着做了,反复配置了许多遍,终于成功了!!!   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-07-23 20:27 | tinsoldier
运行这一页的第二个例子,在Sayhello.jsp页面点submit,每次都出现HTTP404错误。
描述:The requested resource (/Struts2_HelloWorld/HelloWorld) is not available.
为什么啊?   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2008-07-26 10:08 | hfbupt
我一开始也是404错误,后来发现是自己把struts.xml放在了tutorial包里面,导致应用找不到struts.xml中对应的配置,所以出错。   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-07-28 11:59 | 狮子
@WellBeing

你那个是版本 不同了,肯定包少了
   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-07-31 10:42 | 风の稻草
你们不觉得每次打成war包很麻烦吗,还要重启tomcat,不只这样,我还有把tomcat/webapps下的项目文件夹删掉。不知道谁有更快更好的方法。   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-08-13 14:15 | しゅうさん
JDK 1.6.0_03
Eclipse3.3
Tomcat6.0.14
不知道是为什么用Struts2.0.11.1报错
而用Struts2.0.6可以   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-08-15 16:38 | krthur
广大报错404的朋友:
sturts.xml这个配置文件一定要放在web-inf的classes目录下,也就是你新建struts.xml文件是在src建的,而不是在web-inf下面建...
困扰一下午的 resource not avalible终于好了....激动....

   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2008-08-27 17:45 | henry1451
sturts.xml这个配置文件放在src目录下就可以了,工程启动时,会自动拷贝到classes目录下的.   回复   更多评论
  
#  re: 为Struts 2.0做好准备 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.
机器上面装了两个jdk 一个1.4.7一个1.6.7!
tomcat:5.0.23
环境变量:配置的是1.6.7的
各位大侠 怎么回是???   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-09-10 16:47 | dinner1984
严重: Error filterStart
2007-9-13 23:06:10 org.apache.catalina.core.StandardContext start
严重: Context [/Struts2_HelloWorld] startup failed due to previous errors
====================
我也出现这个问题,我是这么解决的,在lib文件夹里面仅仅包含五个基本包。其他的包都删除了。
这五个基本包是: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   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-09-22 18:24 | wangyh
很不错   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-10-06 13:04 | scorpio215
我用eclipse出现了一个问题
我按照JSP教程上的例子 安装了j2sdk-1_4_2_06,,数据库:MySQL 5 以及MySQL图形化管理工具MySQL Administrator1.1.4 MySQL-Front V3.2
开发工具eclipse以及相应的Lomboz插件 WEB服务器Tomcat 5.0.16
现在我新建WEB Dynamic Web Project 项目的时候 点NEXT 下面的窗口一直出不来 不知道是怎么一回事 请指点一下。。。谢谢    回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-10-06 13:05 | scorpio215
如能解决 请加我QQ:232214995 或者发我邮件:scorpio215@126.com
我将万分感激   回复   更多评论
  
#  re: 为Struts 2.0做好准备 2008-10-15 13:54 | asdf
先下载比较新的jdk,别按教程上所说的,一般教程上说的版本都比较老了,eclipse上的所有插件先别装,你先试下看能不能用,一步一步来配置环境   回复   更多评论
  
#  re: 为Struts 2.0做好准备[未登录] 2008-10-25 11:56 | 无名
@风の稻草
把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>   回复   更多评论
  
评论共3页: 1  2  3  下一页 
<script type=text/javascript> function pageLoad() { Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(handleInitializeRequest); //Sys.WebForms.PageRequestManager.getInstance().add_endRequest(handleEndRequest); } function handleInitializeRequest(sender, args) { var prm = Sys.WebForms.PageRequestManager.getInstance(); var eid = args.get_postBackElement().id; if (eid.indexOf("DeleteLink")>0) { args.get_postBackElement().innerHTML = " 正在删除..."; } else if (eid.indexOf("btnSubmit")>0) { document.getElementById("AjaxHolder_PostComment_ltSubmitMsg").innerHTML="正在提交..."; document.getElementById("AjaxHolder_PostComment_btnSubmit").disabled = true; } else if(eid.indexOf("refreshList")>0) { document.getElementById("AjaxHolder_PostComment_refreshList").innerHTML=" 正在刷新..."; } } function TempSave(ElementID) { try { CommentsPersistDiv.setAttribute("CommentContent",document.getElementById(ElementID).value); CommentsPersistDiv.save("CommentXMLStore"); } catch(ex) { } } function Restore(ElementID) { CommentsPersistDiv.load("CommentXMLStore"); document.getElementById(ElementID).value=CommentsPersistDiv.getAttribute("CommentContent"); } </script>

标题
姓名
主页
验证码*  
内容(请不要发表任何与政治相关的内容)
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2007-01-26 16:41 编辑过
 
 
相关链接: <script type=text/javascript> function GetMeta(ametaName){ var METAs = document.getElementsByTagName("meta"); for (var i=0; i "); document.write("
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值