<legend id='FImU5'><style id='FImU5'><dir id='FImU5'><q id='FImU5'></q></dir></style></legend>
      <bdo id='FImU5'></bdo><ul id='FImU5'></ul>

      <tfoot id='FImU5'></tfoot>

    1. <small id='FImU5'></small><noframes id='FImU5'>

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

    2. Struts2 URL 无法访问

      Struts2 URL unreachable(Struts2 URL 无法访问)

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

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

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

                  <tbody id='hbAmb'></tbody>
                <tfoot id='hbAmb'></tfoot>
              1. 本文介绍了Struts2 URL 无法访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我真的在用 Struts2 绞尽脑汁——我可以通过省略部分路径来访问 JSP 页面.注意路径假设包含 pages/welcome_user.jsp.关键是看路径中的pages这个词.

                I'm really racking my head here with Struts2 - I'm able to access the JSP pages by omitting part of the path. Note the path suppose to include pages/welcome_user.jsp. The key is to look at the word pages in the path.

                这是 struts.xml 文件:

                <?xml version="1.0" encoding="UTF-8" ?>
                <!DOCTYPE struts PUBLIC
                "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
                "http://struts.apache.org/dtds/struts-2.0.dtd">
                
                <struts>
                
                    <package name="default" namespace="/User" extends="struts-default">
                        <action name="Login">
                            <result>pages/login.jsp</result>
                        </action>
                        <action name="Welcome" class="com.mkyong.user.action.WelcomeUserAction">
                            <result name="SUCCESS">pages/welcome_user.jsp</result>
                        </action>
                    </package>
                </struts>
                

                我可以通过以下方式访问 login.jsp:http://localhost/Struts2Example/User/Login
                welcome_user.jsp 通过:http://localhost/Struts2Example/User/Welcome
                请注意,在两个 URL 中,我都可以删除 pages,为什么?

                I'm able to access login.jsp via: http://localhost/Struts2Example/User/Login
                and welcome_user.jsp via: http://localhost/Struts2Example/User/Welcome
                Note that in both URL, I'm able to drop pages, why?

                来源:http://www.mkyong.com/misc/how-to-使用-mkyong-tutorial/

                有人可以通过上面的教程告诉我有什么问题吗?

                Can someone go through the above tutorial and tell me what's wrong?

                推荐答案

                首先,您使用了映射到 struts.xml 中操作的 URL.

                First, you have used URLs that are mapped to the actions in the struts.xml.

                action方法被执行并返回结果代码SUCCESS.您可以在操作配置中找到此结果.然后执行result,如果没有设置result类型默认为dispatcher,请求被转发到result配置中指定的位置.

                The action method is executed and returns a result code SUCCESS. This result you can find in the action config. Then result is executed, if the type of result isn't set the default is dispatcher, and request is forwarded to the location specified in the result config.

                如果位置是相对的,则最终的绝对位置将由用于此操作的包的名称空间确定.

                If location is relative the final absolute location will be determined by the namespace of the package used for this action.

                更详细的命名空间使用示例和说明可以在示例 Struts 2 Namespace 配置示例及说明.

                More detailed example of usage namespaces and explanation you can find in the example Struts 2 Namespace configuration example and explanation.

                如果您使用 dispatcher 结果转发到 JSP,则不能删除页面.在这种情况下,URL 已被重写,您无法看到最终 URL.

                You can't drop pages if you are using dispatcher result that forwards to JSP. In this case the URL has been rewritten and you can't see the final URL.

                这篇关于Struts2 URL 无法访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Compiling C++ for the JVM(为 JVM 编译 C++)
                Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)
                <i id='SdV3a'><tr id='SdV3a'><dt id='SdV3a'><q id='SdV3a'><span id='SdV3a'><b id='SdV3a'><form id='SdV3a'><ins id='SdV3a'></ins><ul id='SdV3a'></ul><sub id='SdV3a'></sub></form><legend id='SdV3a'></legend><bdo id='SdV3a'><pre id='SdV3a'><center id='SdV3a'></center></pre></bdo></b><th id='SdV3a'></th></span></q></dt></tr></i><div id='SdV3a'><tfoot id='SdV3a'></tfoot><dl id='SdV3a'><fieldset id='SdV3a'></fieldset></dl></div>
                  <tbody id='SdV3a'></tbody>
              2. <small id='SdV3a'></small><noframes id='SdV3a'>

                <tfoot id='SdV3a'></tfoot>

                    <bdo id='SdV3a'></bdo><ul id='SdV3a'></ul>
                    • <legend id='SdV3a'><style id='SdV3a'><dir id='SdV3a'><q id='SdV3a'></q></dir></style></legend>