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

Struts2新手入门遇到问题
下了个马士兵的视频MyEclipse 7.5+Struts2.1.6我拿来学,我自己用的MyEclipse 6.5+Struts2.1.8.1
配置都按照视频来配了,导包的时候struts-2.1.8.1\apps\struts2-blank-2.1.8.1\WEB-INF\lib只有六个包
而视频中却有九个包,去掉两个无用的,都还有7个包,我的比视频中少一个,六个包是
commons-fileupload-1.2.1.jar commons-io-1.3.2.jar freemarker-2.3.15.jar ognl-2.7.3.jar struts2-core-2.1.8.1.jar xwork-core-2.1.6.jar 2.1.8.1中是不是比2.1.6中要少个包呢?
最后出现个错误,我也不知道错在哪儿
type Status report

message /Struts2_0100_Introduction/hello.action

description The requested resource (/Struts2_0100_Introduction/hello.action) is not available.

下面是我作的配置:希望有用哈~!
struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
  "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<!-- 
  <constant name="struts.enable.DynamicMethodInvocation" value="false" />
  <constant name="struts.devMode" value="false" />

  <include file="example.xml"/>



  <package name="default" namespace="/" extends="struts-default">
  <default-action-ref name="index" />
  <action name="index">
  <result type="redirectAction">
  <param name="actionName">HelloWorld</param>
  <param name="namespace">/example</param>
  </result>
  </action>
  </package>
-->
<package name="default" namespace="/" extends="struts-default">
   
  <action name="hello">
  <result>
  /Hello.jsp
  </result>
  </action>
  </package>
  <!-- Add packages here -->

</struts>


web.xml



<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <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>


我刚学Struts,出门就倒拐,学不起走了...麻烦大家帮我解决下.不甚感激~!


------解决方案--------------------
把class 对应的java类配上!!!!!
------解决方案--------------------
不要class也可以,如果没有配class它会用struts默认的处理类。你上面的问题可能是出来namaspace上。你那个struts.xml里的action里配的是一个客户端跳转到另一个action,又指定了一个命名空间,但并没有对应的action配置,也没有对应的命名空间,再改改配置文件吧
------解决方案--------------------
看看你的项目名称写错没有,不行把namespace="/"去掉试试