栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Struts2通配符映射-更具体的一种由通用类处理

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Struts2通配符映射-更具体的一种由通用类处理

您在操作名称中使用斜杠,该斜杠在通配符映射器中无法正常使用。正如我在链接的答案中所说的,这种情况下最好的模式匹配器是

regex
模式匹配器。

<constant name="struts.patternMatcher" value="regex"/>

请参阅高级通配符。

<action name="/{blogSiteUrl}/{test}"  method="testing">    <result name="success">/WEB-INF/jsp/cmsPages/index.jsp</result></action><action name="/{blogSiteUrl}/postPreview1"  method="test">    <result name="success">/WEB-INF/jsp/cmsPages/templatePicker.jsp</result></action>

关于通配符映射器的文档。让我们看一下示例 空白 应用程序:

<package name="example" namespace="/example" extends="default">    <action name="HelloWorld" >        <result>/WEB-INF/jsp/example/HelloWorld.jsp</result>    </action>    <action name="Login_*" method="{1}" >        <result name="input">/WEB-INF/jsp/example/Login.jsp</result>        <result type="redirectAction">Menu</result>    </action>    <action name="*" >        <result>/WEB-INF/jsp/example/{1}.jsp</result>    </action>    <!-- Add actions here --></package>

因此,URL将按以下顺序进行匹配:

  1. http://localhost:8080/example/HelloWorld
  2. http://localhost:8080/example/Login_input
  3. http://localhost:8080/example/Register

我要说的是,更具体的映射先于较不具体/常见的映射,它之所以会获胜,是因为它是按操作配置的顺序首先找到的。所有与有序配置不匹配的内容都将落入最后一个不太具体的映射。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/438357.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号