我正在致力於struts2-archetype-starter
。通過執行了一個演示struts 2
項目:Struts2:將常量struts.action.extension設置爲「,」不起作用
mvn archetype:generate -B -DgroupId=demoStrutsStarter -DartifactId=DemoStrutsStarter -DarchetypeGroupId=org.apache.struts -DarchetypeArtifactId=struts2-archetype-starter
我修改了struts.xml
,並增加了struts.action.extension
常量聲明。現在,它看起來像這樣:
<?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錯誤,當我鍵入:
http://localhost:8080/DemoStrutsStarter/index
我不知道我在哪裏錯了。任何人都可以請幫我找出爲什麼我無法通過.action擴展名稱進行操作?
是否正在使用您的應用程序W/O'struts.action.extension'? –
是的。無論'struts.action.extension'是否存在,'http:// localhost:8080/DemoStrutsStarter/index.action'總是顯示正確的頁面。但是,在設置爲「,」之後,它不應該。 –