No result defined for action com.jmq.java.action.BookAction and result success 解决struts2问题
程序员文章站
2022-05-24 09:30:53
...
@TNo result defined for action com.jmq.java.action.BookAction and result success 解决struts2问题OC
No result defined for action com.jmq.java.action.BookAction and result success 解决struts2问题
**关于struts2中出现这样的404问题 首先检查有没有配置过滤器和tomcat有无错误 struts.xml中<result
要配对
其次是execute()或其他方法中的返回值必须是String类型!
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<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>
</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>
<package name="book" extends="struts-default">
<action name="book1" class="com.jmq.java.action.BookAction" >
<result name="SUCCESS" >/login.jsp</result>
</action>
</package>
</struts>
action.class
public class BookAction extends ActionSupport {
@Override
public String execute() throws Exception {
System.out.println("成功进入struts2");
System.out.println("hello struts2!!!!");
return SUCCESS;
}
public String login(){
System.out.println("成功进入struts2");
System.out.println("hello struts2!!!!");
return "book";
}
}
这里只要将SUCCESS改成"success"就可以了
上一篇: NSURLSession的簡單使用
下一篇: 小虫代码资源开放库
推荐阅读
-
struts2错误:HTTP Status 404 - No result defined for action xxx and result error
-
Struts2报错:HTTP Status 404 - No result defined for action and result input
-
No result defined for action com.jmq.java.action.BookAction and result success 解决struts2问题
-
2010.09.26———struts2 404 No result defined for action
-
struts2中 No result defined for action
-
struts2的严重问题 No result defined for action ... and
-
Struts2框架后台接收参数乱码问题,No result defined for action action.XxxAction and result error`
-
struts2 明明配置了result 但却提示找不到No result defined for action ……
-
[Struts2] No result defined for action ... and result input & Invalid field value for field ...
-
Struts2 -- No result defined for action action.Register and result success