资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 软件开发 >
Advertisement
文章正文

errors.add("username",new ActionMessage("hello.no.username.error")),可如下报错,初学struts,请指教一下,这里的username与什么有关

类型:转载   责任编辑:asp.net   日期:2007/05/23


热门软件下载:


   

java.lang.ClassCastException:   org.apache.struts.action.ActionMessage  
  java.lang.ClassCastException:   org.apache.struts.action.ActionMessage  
  jsp文件  
  <html:html   locale="true">  
  <head>  
  <title>JSP   for   helloForm   form</title>  
  <html:base/>  
  </head>  
  <body>  
  <html:errors/><p>  
  form.java  
  System.out.println("@@@@@   AAAAAAA   @@@@@@@@@@@");  
  if(userName==null   ||   userName.trim().equals("")){  
  System.out.println("@@@@@   BBBBBBB   @@@@@@@@@@@");  
  errors.add(ActionErrors.GLOBAL_ERROR,new   ActionMessage("hello.no.username.error"));  
  System.out.println("@@@@@@   error   @@@@@@   "   +   errors.toString());  
  }  
  return   errors;

网友回答:

发表者:csqok

hello.no.username.error      
  是对应文件  
  ApplicationResources_ch.properties  
  中的一项的。  
   
  这个文件在strus-config.xml中配置的  
      <!--   ==========   Message   Resources   Definitions   ===========================   -->  
   
      <message-resources         parameter="ApplicationResources_ch.properties"/>  
   
      <message-resources         parameter="AlternateApplicationResources"  
                                                    key="alternate">  
      </message-resources>  
 

发表者:yeshucheng

你的配置信息要在web.xml中加啊!!!!!

发表者:xunyiren

假如要使用username,那么对应的"锚点"username,在什么地方进行设置!!  
   
  这个不需要什么设置!errors.add("username",   new   ActionError("hello.no.username.error"));  
  这个相当于用一个名为"username"的键去映射当用户名为空时的出错信息,这样在页面上显示出错信息时我们就可以指定自己要显示的对应字段的出错信息,而且位置比较灵活,如你有多个表单域  
  html:text   property="userName"/><html:errors   property="username"/>  
  html:text   property="userId"/><html:errors   property="userid"/>  
  这样如果出错,出错信息显示在相应的字段旁边...  
  而如果你想显示在   ActionErrors中保存的所有出错信息时,则只需<html:errors/>这一句。  
 


 

 
热门推荐笔记本: IBM笔记本
相关文章:
笔记本相关:
IT技术文章:
webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
©2007 popbb.net All Rights Reserved