<bdo id='lNgCV'></bdo><ul id='lNgCV'></ul>
  • <legend id='lNgCV'><style id='lNgCV'><dir id='lNgCV'><q id='lNgCV'></q></dir></style></legend>
    <i id='lNgCV'><tr id='lNgCV'><dt id='lNgCV'><q id='lNgCV'><span id='lNgCV'><b id='lNgCV'><form id='lNgCV'><ins id='lNgCV'></ins><ul id='lNgCV'></ul><sub id='lNgCV'></sub></form><legend id='lNgCV'></legend><bdo id='lNgCV'><pre id='lNgCV'><center id='lNgCV'></center></pre></bdo></b><th id='lNgCV'></th></span></q></dt></tr></i><div id='lNgCV'><tfoot id='lNgCV'></tfoot><dl id='lNgCV'><fieldset id='lNgCV'></fieldset></dl></div>
  • <tfoot id='lNgCV'></tfoot>

    <small id='lNgCV'></small><noframes id='lNgCV'>

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

        Struts2 Wildcard Mapping - more specific one is being handled by generic one(Struts2 通配符映射 - 更具体的映射由通用映射处理)
            • <bdo id='wxsVR'></bdo><ul id='wxsVR'></ul>
              <legend id='wxsVR'><style id='wxsVR'><dir id='wxsVR'><q id='wxsVR'></q></dir></style></legend>

                <small id='wxsVR'></small><noframes id='wxsVR'>

                <i id='wxsVR'><tr id='wxsVR'><dt id='wxsVR'><q id='wxsVR'><span id='wxsVR'><b id='wxsVR'><form id='wxsVR'><ins id='wxsVR'></ins><ul id='wxsVR'></ul><sub id='wxsVR'></sub></form><legend id='wxsVR'></legend><bdo id='wxsVR'><pre id='wxsVR'><center id='wxsVR'></center></pre></bdo></b><th id='wxsVR'></th></span></q></dt></tr></i><div id='wxsVR'><tfoot id='wxsVR'></tfoot><dl id='wxsVR'><fieldset id='wxsVR'></fieldset></dl></div>

                  <tfoot id='wxsVR'></tfoot>
                    <tbody id='wxsVR'></tbody>
                  本文介绍了Struts2 通配符映射 - 更具体的映射由通用映射处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我目前正在使用我的 Struts2 配置进行通配符测试,但我坚持使用这个配置.

                  I'm currently playing around with my Struts2 config for wildcard testing and I'm stuck with this one.

                      <action name="/*/*" class="checkBlogUrl" method="testing">
                          <param name="blogSiteUrl">{1}</param>
                          <param name="test">{2}</param>
                          <result name="success">/WEB-INF/jsp/cmsPages/index.jsp</result>
                      </action>
                      
                      <action name="/*/postPreview1" class="blogPostAction" method="test">
                          <param name="blogSiteUrl">{1}</param>
                          <result name="success">/WEB-INF/jsp/cmsPages/templatePicker.jsp</result>
                      </action>
                  

                  如果我访问 myurl.com/hello/hi,我将被重定向到 index.jsp.

                  If I access myurl.com/hello/hi I will be redirected to index.jsp.

                  但如果我访问 myurl.com/hello/postPreview1,我也会被重定向到 index.jsp 而不是 templatePicker.jsp.

                  But if I access myurl.com/hello/postPreview1 I will also be redirected to index.jsp instead of templatePicker.jsp.

                  我在这里做错了吗?struts wildcard doc说最后一个会赢

                  Am I doing something wrong here? The struts wildcard doc said that the last one will win

                  刚刚尝试切换它们并且成功了!我是否误读了文档?

                  Just tried to switch them around and it worked! Am I misreading the doc?

                  推荐答案

                  您在动作名称中使用斜杠,这与通配符映射器一起使用不正确.正如我在链接的 answer 中所说,在这种情况下最好的模式匹配器是 regex 模式匹配器.

                  You are using slashes in action name, that incorrectly works with wildcard mapper. As I said in the linked answer, the best pattern matcher in this case is the regex pattern matcher.

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

                  请参阅高级通配符.

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


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

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


                  所以 URL 将按顺序匹配:


                  So URLs will be matched in the order:

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

                  我会说更具体的映射先于不太具体/常见的映射,它会获胜,因为它在操作配置的顺序中首先找到.与有序配置不匹配的所有内容都属于最后一个不太具体的映射.

                  I would say that more specific mapping goes before less specific/common mapping and it wins because it's found first in the order of action configs. Everything that doesn't match the ordered configs fall into last mapping which is less specific.

                  这篇关于Struts2 通配符映射 - 更具体的映射由通用映射处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Java Bytecode Manipulation Library Suggestions(Java 字节码操作库建议)
                  Java CLI UI-design: frameworks or libraries?(Java CLI UI 设计:框架还是库?)
                  About the use of Beans.xml configuration file in Spring Framework application(关于Spring Framework应用中Beans.xml配置文件的使用)
                  What is the difference between Spring, Struts, Hibernate, JavaServer Faces, Tapestry?(Spring、Struts、Hibernate、JavaServer Faces、Tapestry 有什么区别?)
                  Are there any android application framework like spring?(有没有像spring这样的android应用程序框架?)
                  Java Swing based game framework. Any advice?(基于 Java Swing 的游戏框架.有什么建议吗?)

                  1. <tfoot id='Aw64X'></tfoot>
                        <i id='Aw64X'><tr id='Aw64X'><dt id='Aw64X'><q id='Aw64X'><span id='Aw64X'><b id='Aw64X'><form id='Aw64X'><ins id='Aw64X'></ins><ul id='Aw64X'></ul><sub id='Aw64X'></sub></form><legend id='Aw64X'></legend><bdo id='Aw64X'><pre id='Aw64X'><center id='Aw64X'></center></pre></bdo></b><th id='Aw64X'></th></span></q></dt></tr></i><div id='Aw64X'><tfoot id='Aw64X'></tfoot><dl id='Aw64X'><fieldset id='Aw64X'></fieldset></dl></div>
                        • <bdo id='Aw64X'></bdo><ul id='Aw64X'></ul>

                              <tbody id='Aw64X'></tbody>

                            <small id='Aw64X'></small><noframes id='Aw64X'>

                            <legend id='Aw64X'><style id='Aw64X'><dir id='Aw64X'><q id='Aw64X'></q></dir></style></legend>