无法在Struts 2中执行应用程序 [英] Not able to execute the application in Struts 2

查看:266
本文介绍了无法在Struts 2中执行应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是struts 2的新手,并在其中写了一个helloworld应用程序。但是当我在Tomcat服务器上运行index.jsp文件时会显示

I am new to struts 2 and wrote a helloworld application in it. But when I run the index.jsp file on Tomcat server it displays

配置文件代码是

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                            http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        id="WebApp_ID" version="2.5">
              web.xml
<display-name>mayank</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
         org.apache.struts2.dispatcher.filter.ng.StrutsPrepareAndExecuteFilter
      </filter-class>
   </filter>
   <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
   </filter-mapping>
 </web-app>

struts.xml

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.devMode" value="true" />
      <package name="helloworld" extends="struts-default">
            <action name="hello" class="com.action.HelloWorldAction" method="execute">
            <result name="success">/HelloWorld.jsp</result>
      </action>
   </package>
</struts>

UPDATE:finally解决了很多异常,但现在在struts.xml中出现异常

UPDATE: finally resolved many exceptions but now getting an exception at struts.xml

STACK TRACE:
这是控制台上错误的堆栈跟踪。我认为我的struts.xml有一些问题,但我不能弄清楚。

STACK TRACE: This is the Stack trace of the error on the console. I think there is some problem with my struts.xml but i am not able to figure it out.

Jan 08, 2016 1:17:50 PM org.apache.struts2.dispatcher.Dispatcher warn    WARNING: Could not find action or result: /mayank/hello.action?name=da
    There is no Action mapped for namespace [/] and action name [hello] associated with context path [/mayank]. - [unknown location]
        at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
        at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
        at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
        at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
        at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:554)
        at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
        at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
        at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Unknown Source)


推荐答案

只是把struts.xml放在/ src文件夹中并完成!

I figured out the solution. Just put the struts.xml in the /src folder and done !!!

这篇关于无法在Struts 2中执行应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆