日期:2014-05-17  浏览次数:20690 次

新手学习STRUTS2连jsp页面也开不了
环境 myeclipse 8.6
  tomcat 6.0.35
  struts2.3.3

建立的web service

在src中添加struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<xml-body>
<struts>
  <package name="struts2" namespace="" extends="struts-default">
   
  <action name="l">
  <result>/index.jsp</result>
  </action>
   
   
  </package>
  
</struts>
</xml-body>


修改web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

  <display-name>Struts Blank</display-name>
 <filter>
  <filter-name>struts2</filter-name>
  <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>
struts2 lib下的所有包都引入了
于是访问不了index.jsp了
localhost:8080/struts2/index.jsp 404
localhost:8080/struts2/l.action 404
localhost:8080/struts2 404

删了web.xml就可以了。。但是。。求解啊。。我百度了好久没找打答案。。有人说是webservice的包和strut2的包的冲突了。。但是不摘掉怎么办。。


------解决方案--------------------
建议楼主下回把错误问题贴出来、
要不上面的回答总是乱想、


严重: Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/C:/Users/purple/Desktop/abc/.metadata/.me_tcat/webapps/struts2/WEB-INF/lib/struts2-gxp-plugin-2.3.3.jar!/struts-plugin.xml:8:162


Caused by: Unable to load bean: type:org.apache.struts2.views.gxp.inject.InjectedObjectContainer class:org.apache.struts2.views.gxp.inject.InjectedObjectContainer - bean - jar:file:/C:/Users/purple/Desktop/abc/.metadata/.me_tcat/webapps/struts2/WEB-INF/lib/struts2-gxp-plugin-2.3.3.jar!/struts-plugin.xml:8:162

另外建议楼主照个例子动手弄下、

可以自己定义变量、但是别太难懂的变量了