我使用了 Struts2 Annotation
我web.xml
的是:
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<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>
我的 JSP 是:
<s:form action="test" method="post">
<s:textfield name="id" label="Id"></s:textfield>
<s:submit value="Submit"></s:submit>
</s:form>
我的课是:
@Namespace("/")
public class Test extends ActionSupport {
private static final long serialVersionUID = 1L;
@Action(value = "test", results = { @Result(name = "success", location = "success.jsp") })
public String input() {
System.out.println("input call");
return SUCCESS;
}
}
我收到错误:
HTTP Status 404 - There is no Action mapped for namespace / and action name test.
文件夹结构: