关于ssh web 项目出现 No result defined for action comindex.action and result success解决办法
来源:互联网 发布:pc版拼图软件 编辑:程序博客网 时间:2024/06/02 04:37
在我学习写ssh项目联系的时候,出现了:
“HTTP Status 404 - No result defined for action com.hry.shop.index.action.IndexAction and result success”的错误提示。
大致意思就是说我没有在Action方法中定义返回值,来让struts做判断跳转页面。下面附上我学习写的代码。
Action中的代码:
package com.hry.shop.index.action;import com.opensymphony.xwork2.ActionSupport;public class IndexAction extends ActionSupport {/** * * @return */public String index() {return "index_ok";}}
struts.xml中的代码
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN""http://struts.apache.org/dtds/struts-2.3.dtd"><struts><package name="shop" extends="struts-default" namespace="/"><!-- 配置访问首页的Action --><action name="index" class="indexAction"><result name="index_ok">/WEB-INF/jsp/index.jsp</result></action></package></struts>
我明明定义了返回值和一样的返回值名称,为什么还是提示我没有定义呢?这个问题经过好久才得到解决。我对Action中的代码做了一些更改。package com.hry.shop.index.action;import com.opensymphony.xwork2.ActionSupport;public class IndexAction extends ActionSupport {/** * * @return */public String execute() {return "index_ok";}}
然后程序就能够成功执行了。通过搜索发现是这样解释的:如果你的Action类是继承自ActionSupport的话,确切的说是重写了execute方法,ActionSupport里的默认实现就是返回"success"视图。因此,你可以不实现execute方法,只要你的struts.xml里有"success"对应的result即可。如果你的Action类没有继承ActionSupport,而你又没有在struts.xml中对应<action>标签中用method属性指定你自己的方法的话,默认就要找execute方法,这时是必须要实现execute方法的,否则Struts2会找不到对应的方法而报错。
阅读全文
0 0
- 关于ssh web 项目出现 No result defined for action comindex.action and result success解决办法
- No result defined for action action.LoginAction and result success
- No result defined for action action.LoginAction and result success
- No result defined for action Action.calculation and result success
- No result defined for action action.LoginAction and result success
- No result defined for Action and result success
- No result defined for action and result success 的问题
- No result defined for action jsp_entity.SysLog and result success
- No result defined for action *** and result success
- No result defined for Action and result success
- struts异常:No result defined for action and result success
- No result defined for action and result success
- 关于No result defined for action org.action.StrutsAction and result success
- 关于No result defined for Action and result success问题解决办法的总结
- struts2 关于 No result defined for action and result success 的问题
- struts2 关于 No result defined for action and result success 的问题
- [SSH]Struts2 -- No result defined for action and result input
- action莫名报错 No result defined for action com.action.Logout and result success
- 杭电ACM OJ 1019 Least Common Multiple 质因子最快速求最大公因数和最小公倍数
- Dockerfile语法
- tomcat可以正常启动但是在Eclipse下不可以正常启动
- C语言的指针
- springmvc配置文件:project-db.properties
- 关于ssh web 项目出现 No result defined for action comindex.action and result success解决办法
- 第一个树莓派JAVA测试程序-LED灯控制
- fastdfs 缩略图
- 介绍一款不错的C/C++开发工具:CodeBlocks
- Qt MySQL 时间处理
- spring boot 基础(一)
- 一个完整最少代码的上拉加载(mint-ui的loadmore 和 vue)
- javaEE(文件上传和下载)
- 一些概念