首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

Struts客户化标签<html:error/>不知道为什么不能显示错误信息?

2014-01-26 
JSP代码:%@ page contentTypetext/htmlcharsetGBK languagejava %%@ taglib uri/WEB-INF/stru

JSP代码:
  <%@ page contentType="text/html;charset=GBK" language="java" %>
  <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
  <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
  <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
 
  <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">
  <!-- 判断JavaBean在指定的范围是否存在,View与Model组件传递数据是通过request的setAttritute,getAttribute来实现-->
  <h2>
  <bean:message key="hello.jsp.page.hello"/><!-- 输出本地化的信息-->
  <bean:write name="personbean" property="userName" />!<!--输入JavaBean的属性值 --><p>
  </h2>
  </logic:present>
 
  <html:form action="/HelloWorld.do" focus="userName" ><!-- 创建HTML表单-->
  <bean:message key="hello.jsp.prompt.person"/>
  <html:text property="userName" size="16" maxlength="16"/><br><!-- 该值与ActionForm Bean的属性值对应-->
  <html:submit property="submit" value="Submit"/>
  <html:reset/>
 
  </html:form><br>
 
 
  </body>
  </html:html>
 
 
  ActionForm Bean代码:
  package hello;
 
  import javax.servlet.http.HttpServletRequest;
  import org.apache.struts.action.ActionMessage;
  import org.apache.struts.action.ActionMessages;
  import org.apache.struts.action.ActionErrors;
  import org.apache.struts.action.ActionError;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionMapping;
 
  public final class HelloForm extends ActionForm {
 
  private String userName = null;
 
  public String getUserName() {
  return (this.userName);
  }
 
  public void setUserName(String userName) {
  this.userName = userName;
  }
 
  /**
  * Reset all properties to their default values.         

热点排行