Struts2:将常量struts.action.extension设置为“,".不工作 [英] Struts2: Setting constant struts.action.extension to "," not working
问题描述
我正在研究struts2-archetype-starter
.通过执行以下操作获得演示struts 2
演示项目:
I am working on struts2-archetype-starter
. Got a demo struts 2
project by executing:
mvn archetype:generate -B -DgroupId=demoStrutsStarter -DartifactId=DemoStrutsStarter -DarchetypeGroupId=org.apache.struts -DarchetypeArtifactId=struts2-archetype-starter
我修改了struts.xml
并添加了struts.action.extension
常量声明.现在看起来像这样:
I modified my struts.xml
and added a struts.action.extension
constant declaration. Now it looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.action.extension" value=","/>
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
<package name="myPackage" extends="struts-default">
<default-action-ref name="index" />
<action name="index" class="demoStrutsStarter.IndexAction">
<result>/jsp/index.jsp</result>
</action>
<action name="helloWorld" class="demoStrutsStarter.HelloWorldAction">
<result name="input">/jsp/index.jsp</result>
<result>/jsp/helloWorld.jsp</result>
</action>
</package>
</struts>
但是,当我输入以下内容时,我收到404错误
But, I am getting a 404 error when I type:
http://localhost:8080/DemoStrutsStarter/index
我不确定我哪里错了.有人可以帮我找出为什么没有 .action 分机无法拨打电话的原因吗?
I am not sure where I am wrong. Can anybody please help me find out why I am unable to call actions without .action extension?
推荐答案
在两个结果中都尝试一下
结果1
<result>/WEB-INF/jsp/index.jsp</result>
结果2
<result>/WEB-INF/jsp/helloWorld.jsp</result>
否则请检查您的包裹名称是否正确. 默认情况下,其名称为默认
else check your package name is correct or not. by default, it's name default
尝试此链接.可能有帮助
try this links. it may help
1.堆栈溢出链接1
3.堆栈溢出链接3
这篇关于Struts2:将常量struts.action.extension设置为“,".不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!