Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Struts2 “不影响”;“结果路径”;struts.xml中的常量_Struts2 - Fatal编程技术网

Struts2 “不影响”;“结果路径”;struts.xml中的常量

Struts2 “不影响”;“结果路径”;struts.xml中的常量,struts2,Struts2,我在WebContent文件夹中有所有jsp页面(例如:index.jsp),我的应用程序运行正常。 现在,我在WebContent中创建了一个文件夹“pages”,在那里我传输了所有jsp页面 我在标记中添加了以下行: <constant name="struts.convention.result.path" value="/pages" /> 但是,它仍然没有在“pages”文件夹中搜索jsp。 我得到: HTTP状态404-/MyApplicationName/inde

我在WebContent文件夹中有所有jsp页面(例如:index.jsp),我的应用程序运行正常。 现在,我在WebContent中创建了一个文件夹“pages”,在那里我传输了所有jsp页面

我在
标记中添加了以下行:

<constant name="struts.convention.result.path" value="/pages" />

但是,它仍然没有在“pages”文件夹中搜索jsp。 我得到:

HTTP状态404-/MyApplicationName/index.jsp

我哪里做错了

编辑:我的应用程序的当前结构如下:

欢迎页面是一个操作,而不是jsp页面。此操作的结果页是index.jsp。此操作填充index.jsp中的下拉菜单和一些其他字段。现在,我想将index.jsp与其他jsp页面一起保存在“WebContent/pages”文件夹中。我的应用程序中有30多个jsp页面,我不想在结果标记中提及每个jsp的完整路径。这就是为什么我想使用struts2常量“struts.convention.result.path”


我的问题是,为什么我上面提到的代码不起作用?

访问
index.jsp
直接绕过所有S2请求处理


没有涉及S2或S2约定插件,您只是访问一个JSP页面。

如果
index.JSP
是应用程序的第一个页面,那么您需要在web.xml的
标记中将其路径更改为/pages/index.JSP。剩下的我同意@Dave Newton:)

可能您的错误是在struts.xml中

当您在
网站内容
下创建
新文件夹
时,请使用

xml文件
在src
下,并将其包含在
struts.xml
文件中,它将正常工作

例如:假设您在web内容下创建了
示例文件夹
,现在创建example.xml文件

在src文件夹下和struts.xml文件中包含example.xml

example.xml:


struts.xml:



发布您的配置详细信息。如果您使用的是
Struts2约定插件
,请尝试
index.action
将页面直接放在/WEB-INF/content/(不需要“struts.Convention.result.path”或至少“/WEB-INF/pages/”下,以强制Struts2参与,但您需要结果路径集)。此外,如果您真的需要该扩展,您还需要将struts2操作扩展设置为包含jsp。我没试过这个。。。我认为,如果您想对用户隐藏细节,最好将操作扩展设置为html。Jsp不是一个好的选择,因为您可能需要使用不同的视图技术,这会有点混乱。在web.xml文件中显示您的
。您解决了问题吗?谢谢。顺便说一下,不需要创建名为example的文件夹。我知道如何在struts.xml中包含xml文件。问题是,如何使用struts2中的常量result.path使服务器在特定位置查找结果页,这比在结果标记中提及每个结果页的完整路径要好。
<struts>

    <package name="example" namespace="/example" extends="default">
     <action name="your action name" class="your class" method="your method">
     </action> 
</package>
</struts>
<struts>

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

<action  name="" class="" method="">
</action>
</package>

<include file="example.xml"/>