无法运行基于struts框架的应用程序 [英] Unable to run application based on struts framework
问题描述
我正在使用 struts.xml
文件,如下所述:
I am using struts.xml
file which is described below :
<?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" />
<constant name="struts.multipart.maxSize" value="1000000" />
<package name="helloworld" extends="struts-default">
<interceptors>
<interceptor name="myinterceptor"
class="com.struts2examples.MyInterceptor" />
<interceptor name="myinterceptor1"
class="com.struts2examples.MyInterceptor1" />
</interceptors>
<action name="hello"
class="com.struts2examples.HelloWorldAction"
method="execute">
<result name="success">/HelloWorld.jsp</result>
<result name="error">/AccessDenied.jsp</result>
<interceptor-ref name="params"/>
<interceptor-ref name="myinterceptor"/>
<interceptor-ref name="myinterceptor1"/>
</action>
<action name="hello1"
class="com.struts2examples.HelloWorldAction1"
method="execute">
<result name="success" type="freemarker">
<param name="location">/hello.fm</param>
</result>
<result name="nopassnofail" type="redirect">
<param name="location">/NewWorld.jsp</param >
</result>
<result name="error">/AccessDenied.jsp</result>
</action>
<action name="upload" class="com.struts2examples.UploadFile" method="execute">
<interceptor-ref name="fileUpload">
<param name="allowedTypes">image/jpeg,image/gif</param>
</interceptor-ref>
<result name="success">/success.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>
</struts>
在我添加上一个操作上传之前,它正常工作。当我启动服务器时,它显示404错误。有人可以帮助我解决这个问题。我觉得问题是由于< interceptor-ref name =fileUpload>
。
It was working before I added the last action "upload". When I start the server it is showing me the 404 error. Can somebody help me out in resolving the issue. I am feeling that the issue is due to <interceptor-ref name="fileUpload">
.
推荐答案
尝试在< interceptor-ref name =fileUpload>
< interceptor-ref之后添加NAME = defaultStack >
。如果向动作添加显式拦截器,则 defaultStack
消失。
Try to add after <interceptor-ref name="fileUpload">
<interceptor-ref name="defaultStack">
. If you add explicit interceptor to the action the defaultStack
disappears.
这篇关于无法运行基于struts框架的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!