Cannot retrieve definition for form bean null on action错误

本文通过解决Struts框架中的一个具体问题——“Cannot retrieve definition for form bean null”错误,介绍了在使用<html:form>标签时创建相应form-bean的必要性,并分享了解决该问题的过程和心得。

 

================代码开始===============
jsp:<html:form action="/admin/exit.do"><input type="image" src="images/quit.gif" width="69" height="17"/>< ml:form>
config页面:
<action path="/admin/exit"
    type="com.jpkc.admin.action.LogoutAction"
 >
    <forward name="login" path="/admin/login.jsp"/>
</action>

java文件:
public class LogoutAction extends Action {

 @Override
 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
 
  HttpSession session = request.getSession(true);
  session.removeAttribute("username");
  return mapping.findForward("login");
 }

}

==================代码结束===============
<input type="image" src="images/quit.gif" width="69" height="17"/>改成:
<html:form action="/admin/exit.do"><input type="submit" value="退出" name="submit" width="69" height="17"/>< ml:form>还不行还是出现 Cannot retrieve definition for form bean null on action /admin/exit.do这个错误。

如果要用到html:form标签则在strtus-config.xml中必须为其创建form-beans
java_jr(275451870) 00:31:09
成功显示,换成<html:link/>就行了,哈哈。。

==========调试成功=============

 

结论:困扰了大半天,在群里也是没人能明白,到网上查了错误才了解到如果jsp页面中要用到<html:form action=""></html:form>标签的 话务必得创建它的form-bean,否则就会提示Cannot retrieve mapping for action这个错误。

### 解决 EPEL 仓库无法获取 metalink 的问题 在使用 `yum` 安装软件包时,若遇到 `Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again` 错误,通常表示系统无法访问或解析 EPEL 仓库的镜像列表。该问题可能由网络连接异常、SSL 配置错误、EPEL 源配置不当或缓存失效引起。 一种常见的解决方法是将 EPEL 源的 `mirrorlist` 替换为直接的 `baseurl`,以避免依赖于动态镜像选择机制。编辑 `/etc/yum.repos.d/epel.repo` 文件,将以下内容: ```ini [epel] name=Extra Packages for Enterprise Linux 6 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch ``` 替换为: ```ini [epel] name=Extra Packages for Enterprise Linux 6 - $basearch baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch ``` 这样可以绕过金属链接(metalink)机制,直接指定基础 URL 来下载元数据[^3]。 另一种方法是在执行安装命令时临时禁用 EPEL 仓库,并清理 YUM 缓存以确保不会使用损坏的数据。运行以下命令: ```bash yum clean all yum --disablerepo=epel install redis -y ``` 如果仍然提示找不到可用软件包,则需要检查 EPEL 源是否已正确安装和配置。重新安装 EPEL 仓库可能会解决问题: ```bash yum remove epel-release yum install epel-release ``` 此外,还应确认系统的日期和时间设置是否准确,因为 SSL 证书验证依赖于正确的系统时间。使用 `ntpdate` 或 `timedatectl` 工具同步系统时钟: ```bash timedatectl set-ntp true ``` 最后,检查服务器的 DNS 设置和防火墙规则,确保能够正常访问外部仓库站点。必要时可尝试更换 DNS 服务器,例如使用 Google Public DNS(8.8.8.8 和 8.8.4.4)进行测试。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值