我是 struts2 的新手,正在尝试学习非常棒的 struts2 框架。
但是我一直坚持一个非常关键的问题,如上所述:
没有为命名空间/和操作名称 Struts2Example1 映射的操作。
我正在使用 IntelliJ IDE,我的 web.xml 的内容是:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID"
version="2.5">
<display-name>Struts2Example2</display-name>
<filter>
<filter-name>struts2</filter-name>
<!--<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>-->
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
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>
</struts>
任何人都可以帮助我消除这个错误。
谢谢
最佳答案
学习一个新框架的最好方法是从struts2官网下载一些示例应用程序,检查它们是如何配置和运行的 Download Example Applications:
根据您在查询中的描述,您的配置文件似乎存在一些映射问题 更多关于您提供的 struts.xml 文件不包含任何映射条目,因此最好提供完整的详细信息
关于Java Struts2 Action map 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6723406/