struts标签的用法

passwords passwords 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
----------------------------------jsp-------------------------------------
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:html locale="true">
<head>
<title><bean:message key="hello.jsp.title"/></title>
<html:base/>
</head>
<body bgcolor="white"><p>
<h2><bean:message key="hello.jsp.page.heading"/></h2><p>
<html:errors/><p>
<logic:present name="personbean" scope="request">
<h2>
<bean:message key="hello.jsp.page.hello"/>
<bean:write name="personbean" property="userName"/>!<p>
</h2>
</logic:present>
<html:form action="/helloAction.do" focus="userName">
<bean:message key="hello.jsp.prompt.person"/>
<html:text property="userName" size="6" maxlength="16"/><br>
<html:submit property="submit" value="submit"/>
<html:reset/>
</html:form><br>
</body>
</html:html>



---------------------------------------------actionForm------------------------------
package hello;

import org.apache.struts.action.*;
import javax.servlet.http.*;
public class HelloForm extends ActionForm {
private String userName=null;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
/**@todo: finish this method, this is just the skeleton.*/
ActionErrors errors=new ActionErrors();
if((userName==null||(userName.length()<1)))
errors.add("username",new ActionMessage("hello.no.username.error"));
return errors;
}
public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
userName = null;
}
}



进行actionform验证时返回jsp时到<html:errors/>标签时报
java.lang.ClassCastException
at org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
怎么解决!!
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
passwords
Java EE 67,535 成员 225,843 内容