<tfoot id='I4kMX'></tfoot>
      1. <legend id='I4kMX'><style id='I4kMX'><dir id='I4kMX'><q id='I4kMX'></q></dir></style></legend>

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

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

        Struts 2 - HTTP 状态 404 - 没有为操作定义结果

        Struts 2 - HTTP Status 404 - No result defined for action(Struts 2 - HTTP 状态 404 - 没有为操作定义结果)
          <bdo id='4pVfs'></bdo><ul id='4pVfs'></ul>
            <tfoot id='4pVfs'></tfoot>

                  <tbody id='4pVfs'></tbody>

              1. <legend id='4pVfs'><style id='4pVfs'><dir id='4pVfs'><q id='4pVfs'></q></dir></style></legend>

              2. <small id='4pVfs'></small><noframes id='4pVfs'>

                • <i id='4pVfs'><tr id='4pVfs'><dt id='4pVfs'><q id='4pVfs'><span id='4pVfs'><b id='4pVfs'><form id='4pVfs'><ins id='4pVfs'></ins><ul id='4pVfs'></ul><sub id='4pVfs'></sub></form><legend id='4pVfs'></legend><bdo id='4pVfs'><pre id='4pVfs'><center id='4pVfs'></center></pre></bdo></b><th id='4pVfs'></th></span></q></dt></tr></i><div id='4pVfs'><tfoot id='4pVfs'></tfoot><dl id='4pVfs'><fieldset id='4pVfs'></fieldset></dl></div>
                  本文介绍了Struts 2 - HTTP 状态 404 - 没有为操作定义结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试开发一个 Struts2 应用程序,其中在单击超链接时调用一个动作,该超链接使用 Struts 动作映射将用户引导到 hello.jsp.我收到以下错误:

                  I'm trying to develop a Struts2 app where an action is invoked upon clicking a hyperlink which directs the user to a hello.jsp using Struts action mapping. I'm getting the following error:

                  HTTP Status 404 - No result defined for action com.manaar.action.HelloAction and result success
                  

                  我的文件如下.我的映射看起来井井有条.我还检查了此处的其他帖子,但似乎找不到此问题的原因或解决方案.非常感谢任何建议.非常感谢,J

                  My files are as follows. My mapping looks like it's in order. I also checked other postings on here but can't seem to find the cause or solution to this problem. Would really appreciate any advice. Many thanks, J

                  index.jsp:

                  <%@ page contentType="text/html;charset=UTF-8" language="java"%>
                  <%@ taglib uri="/struts-tags" prefix="s"%>
                  <html>
                  <head>
                      <title><s:text name="app.title" /></title>
                      <link rel="stylesheet" href="mystyle.css" type="text/css" />
                  </head>
                  <body>
                  <center>
                      <h2>
                          Struts 2 Actions
                      </h2>
                      <br>
                      <br>
                      Welcome
                      <s:property value="#session.user" default="Guest" />!
                      <s:if test="#session.user!=null">
                          <s:url id="logout" action="logout" />
                          | <s:a href="%{logout}">Logout</s:a> |
                      </s:if>
                      <br>
                      <table cellspacing="5" width="180">
                          <tr bgcolor="#f0edd9" height="25" align="center">
                              <td>
                                  <s:url id="hello" action="hello"/>
                                  <s:a href="%{hello}">Hello Action</s:a>
                                  </td>
                              </tr>
                              <tr bgcolor="#f0edd9" height="25" align="center">
                                  <td>
                                  <s:a href="add_user.jsp">Add User</s:a>
                                  </td>
                              </tr>
                              <tr bgcolor="#f0edd9" height="25" align="center">
                                  <td>
                                  <s:a href="user.jsp">View Users</s:a>
                                  </td>
                              </tr>
                              <tr bgcolor="#f0edd9" height="25" align="center">
                                  <td>
                                  <s:a href="login.jsp">Login</s:a>
                              </td>
                          </tr>
                      </table>
                  </center>
                  </body>
                  </html>
                  

                  struts.xml:

                  <!DOCTYPE struts PUBLIC
                  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
                  "http://struts.apache.org/dtds/struts-2.0.dtd">
                  
                  <struts>
                  <!-- Configuration for the default package. -->
                  <package name="default" extends="struts-default">
                      <action name="hello" class="com.manaar.action.HelloAction" method="wateva">
                          <result name="success">/hello.jsp</result>
                      </action>
                  </package>
                  

                  HelloAction.java:

                  /*
                   * To change this template, choose Tools | Templates
                   * and open the template in the editor.
                   */
                  package com.manaar.action;
                  import com.opensymphony.xwork2.Action;
                  import static com.opensymphony.xwork2.Action.SUCCESS; 
                  
                  public class HelloAction implements Action {
                  
                  String message;
                  
                  public String getMessage() {
                      return message;
                  }
                  
                  public void setMessage(String message) {
                      this.message = message;
                  }
                  
                      /**
                   *
                   * @return
                   * @throws Exception
                   */
                  @Override
                  public String execute() throws Exception {
                      setMessage("Hello From Struts!");
                      return SUCCESS;
                  }
                  }
                  

                  推荐答案

                  你可以使用 config-浏览器插件.如果您想在浏览器中查看配置以及操作如何映射到 URL,这将非常有用.

                  You could use a config-browser plugin. It's useful if you want to see the configuration in the browser and how actions are mapped to the URLs.

                  其实问题的原因在于你使用了一个convention-plugin.如果您将 struts2-convention-plugin-2.3.x.jar 放入 WEB-INF/lib 中,就会使用它.安装后,它会扫描在 struts-plugin.xml 中定义的包,并按照约定为 struts.xml 配置创建一个附加项.除了您的操作符合插件使用的规则外,操作 hello" 是为类 HelloAction 创建的,但不幸的是它没有结果 "成功".要将此结果添加到操作中,您应该在类上使用 @Result 注释,或使用 @ResultPath 注释来指定结果的路径而不是默认路径WEB-INF/内容.如果您应用 struts.convention.result.path 配置设置,也可以这样做.

                  Actually, the cause of the problem that you use a convention-plugin. It's used if you put struts2-convention-plugin-2.3.x.jar into WEB-INF/lib. When installed it scans the packages, defined in the struts-plugin.xml and creates an additional to struts.xml configuration by conventions. As well as your action is comply the rules used by the plugin the action "hello" is created for the class HelloAction but unfortunately it has no a result "success". To add this result to the action you should use @Result annotation on the class, or use @ResultPath annotation to specify the path to results where they could be located instead of default WEB-INF/content. The same could be done if you apply struts.convention.result.path configuration settings.

                  @Result(name = SUCCESS, location = "/hello.jsp")
                  

                  还请注意,您在 struts.xml 中为动作 hello" 定义的映射意义不大,除非它映射到指定的方法.JSP 的名称假设 index.jsp 有错字.

                  Also note, that the mapping you defined in the struts.xml for the action "hello" has less meaning unless it mapped to the method specified. And name of the JSP supposed a typo for index.jsp.

                  这篇关于Struts 2 - HTTP 状态 404 - 没有为操作定义结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的游戏框架.有什么建议吗?)
                • <tfoot id='UCYKe'></tfoot>

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

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

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

                              <tbody id='UCYKe'></tbody>