struts2,Could not execute action: /newAction There is no Action mapped for action name newAction. – [unknown location]

huangapple 未分类评论48阅读模式
英文:

struts2,Could not execute action: /newAction There is no Action mapped for action name newAction. - [unknown location]

问题

  1. >struts2,无法执行操作:/newAction。没有为操作名称newAction映射的操作。 - [位置未知]
  2. 目录和错误信息
  3. ![目录和错误信息][1]
  4. 以下是文件内容,我不知道为什么会这样。拜托了,我快要疯了。
  5. <%--new.jsp--%>
  6. <%@ taglib prefix="s" uri="/struts-tags" %>
  7. <%@ page contentType="text/html;charset=UTF-8" %>
  8. <html>
  9. <head>
  10. <title>new.jsp</title>
  11. </head>
  12. <body>
  13. new
  14. <s:action name="newAction"/>
  15. </body>
  16. </html>
  17. <%-- a.jsp--%>
  18. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  19. <html>
  20. <head>
  21. <title>Title</title>
  22. </head>
  23. <body>
  24. a
  25. </body>
  26. </html>
  27. <%!--struts2.xml--%>
  28. <struts>
  29. <constant name="struts.enable.DynamicMethodInvocation" value="true"/>
  30. <constant name="struts.devMode" value="true"/>
  31. <package name="homework6" extends="struts-default">
  32. <action name="newAction" class="homework6.action.NewAction">
  33. <result name="success">/a.jsp</result>
  34. </action>
  35. </package>
  36. </struts>
  37. //NewAction
  38. package homework6.action;
  39. import com.opensymphony.xwork2.ActionSupport;
  40. public class NewAction extends ActionSupport {
  41. @Override
  42. public String execute() throws Exception {
  43. return SUCCESS;
  44. }
  45. }
  46. <?xml version="1.0" encoding="UTF-8"?>
  47. <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  48. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  49. xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
  50. version="4.0">
  51. <display-name>default</display-name>
  52. <welcome-file-list>
  53. <welcome-file>new.jsp</welcome-file>
  54. <welcome-file>a.jsp</welcome-file>
  55. </welcome-file-list>
  56. <filter>
  57. <filter-name>struts2</filter-name>
  58. <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
  59. </filter>
  60. <filter-mapping>
  61. <filter-name>struts2</filter-name>
  62. <url-pattern>/*</url-pattern>
  63. </filter-mapping>
  64. </web-app>
  65. [1]: https://i.stack.imgur.com/2y4Eh.png
英文:

>struts2,Could not execute action: /newAction There is no Action mapped for action name newAction. - [unknown location]

Directory and error information

struts2,Could not execute action: /newAction There is no Action mapped for action name newAction. – [unknown location]

Files are as follows, I do not know why it will be like that. Please, I am almost mad.

  1. <%--new.jsp--%>
  2. <%@ taglib prefix="s" uri="/struts-tags" %>
  3. <%@ page contentType="text/html;charset=UTF-8" %>
  4. <html>
  5. <head>
  6. <title>new.jsp</title>
  7. </head>
  8. <body>
  9. new
  10. <s:action name="newAction"/>
  11. </body>
  12. </html>
  1. <%-- a.jsp--%>
  2. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  3. <html>
  4. <head>
  5. <title>Title</title>
  6. </head>
  7. <body>
  8. a
  9. </body>
  10. </html>
  1. <%!--struts2.xml--%>
  2. <struts>
  3. <constant name="struts.enable.DynamicMethodInvocation" value="true"/>
  4. <constant name="struts.devMode" value="true"/>
  5. <package name="homework6" extends="struts-default">
  6. <action name="newAction" class="homework6.action.NewAction">
  7. <result name="success">/a.jsp</result>
  8. </action>
  9. </package>
  10. </struts>
  1. //NewAction
  2. package homework6.action;
  3. import com.opensymphony.xwork2.ActionSupport;
  4. public class NewAction extends ActionSupport {
  5. @Override
  6. public String execute() throws Exception {
  7. return SUCCESS;
  8. }
  9. }
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
  5. version="4.0">
  6. <display-name>default</display-name>
  7. <welcome-file-list>
  8. <welcome-file>new.jsp</welcome-file>
  9. <welcome-file>a.jsp</welcome-file>
  10. </welcome-file-list>
  11. <filter>
  12. <filter-name>struts2</filter-name>
  13. <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
  14. </filter>
  15. <filter-mapping>
  16. <filter-name>struts2</filter-name>
  17. <url-pattern>/*</url-pattern>
  18. </filter-mapping>
  19. </web-app>

答案1

得分: 0

查看“入门”文档中的struts.xml部分

Struts 2配置文件的默认名称是struts.xml

英文:

See the struts.xml section of the "Getting Started" docs.

The default name of the Struts 2 configuration file is struts.xml.

huangapple
  • 本文由 发表于 2020年4月10日 19:49:24
  • 转载请务必保留本文链接:https://java.coder-hub.com/61139645.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定