struts标签的用法
----------------------------------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)
怎么解决!!
<%@ 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)
怎么解决!!
...全文
相关推荐
struts2标签用法详解
在本文中,我们将深入探讨Struts2标签的用法,包括它们的基本概念、类型以及如何在实际开发中应用。
struts2标签用法
下面将详细介绍Struts2标签的用法。1. **Action标签**:这是最基础的标签,用于调用Action类。
Struts2通用标签用法示例
该项目演示了Struts2框架中通用标签的用法,包含完整的Web应用配置。通过struts.xml定义动作映射与参数设置,web.xml集成Struts2核心过滤器,实现请求分发。项目基于Java E
struts1中的logic标签用法
"struts1中的logic标签用法"在Struts1框架中,logic标签库是用于处理条件逻辑的一种强大的工具,它简化了在JSP页面中进行条件判断的复杂性,使得开发者能够更专注于业务逻辑,而不
struts2 doubleselect标签的用法例子
在"struts2 doubleselect标签的用法例子"中,我们将探讨如何实现这个功能。首先,我们需要理解`doubleselect`标签的基本结构和属性。


