Java中 Cannot retrieve definition 错误解决
1、jsp文件:<html:form action="/admin/exit.do"><input type="image" src="images/quit.gif" width="69" height="17"/>< ml:form>
2、config页面:<action path="/admin/exit" type="com.jpkc.admin.action.LogoutAction"> <forward name="login" path="/admin/login.jsp"/></action>
3、Java文件:public class LogoutA罕铞泱殳ction extends Action {@Ov髫潋啜缅erridepublic ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {HttpSession session = request.getSession(true);session.removeAttribute("username");return mapping.findForward("login");}}
4、<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这个错误。
5、如果要用到html:form标签则在strtus-config.xml中必须为其创建form-beans成功显示,换成<html:link/>就行了困扰了大半天,在群里也是没人能明白,到网上查了错误才了解到如果jsp页面中要用到<html:form action=""></html:form>标签的 话务必得创建它的form-bean,否则就会提示Cannot retrieve mapping for action这个错误。