请教高手,为什么就是显示不出来???

bisliu 2005-07-14 09:19:13
在action类中
ActionErrors errors = new ActionErrors();
errors.add("errorTest",new ActionError("error.test"));
saveErrors(request, errors);
return new ActionForward(actionMapping.getInput());
..........
文件设置如下:
struts\WEB-INF\classes\ApplicationResources.properties
ApplicationResources.properties中有
error.test=this is a test!
config-struts.xml中已加上
<message-resources parameter="ApplicationResources" />
web-config.xml中也加上了
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
jsp页面中使用<html:errors/>来显示错误信息,可是总也没显示出来,但也不报错,不知道为什么?搞了一天,论坛上也搜了个遍,实在是没办法了,望哪位高手来帮帮忙,感激不尽!!
...全文
390 28 打赏 收藏 转发到动态 举报
写回复
用AI写文章
28 条回复
切换为时间正序
请发表友善的回复…
发表回复
TheTens 2005-11-30
  • 打赏
  • 举报
回复
http://blog.sina.com.cn/u/465be2c3010000ql
bisliu 2005-08-30
  • 打赏
  • 举报
回复
确实问题比较怪,配置都肯定没错的,好像是环境问题
大河V5 2005-07-25
  • 打赏
  • 举报
回复
感觉象是没读到ApplicationResources.properties这个文件

你的资源文件在class里有吗?不要只是在src里面,没有放到class中。
MARS.nEIL 2005-07-25
  • 打赏
  • 举报
回复
随便加一条信息,然后看能不能显示出来。
leipub 2005-07-25
  • 打赏
  • 举报
回复
没有在Struts里面配置plug-in
bisliu 2005-07-18
  • 打赏
  • 举报
回复
感觉象是没读到ApplicationResources.properties这个文件,找到个例子,可以显示出errors,发现在启服务的时候,控制台会出现
2005-7-18 20:22:44 org.apache.struts.util.PropertyMessageResources <init>
信息: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=tru
e
2005-7-18 20:22:45 org.apache.struts.util.PropertyMessageResources <init>
信息: Initializing, config='org.apache.struts.action.ActionResources', returnNul
l=true
而我的是不会,所以errors显示不出来,那这是在哪个文件里做配置的呢?
bisliu 2005-07-18
  • 打赏
  • 举报
回复
我试过了,好像不是validate的问题
leipub 2005-07-18
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<!-- ======================== Form Bean Definitions ================ -->
<form-beans>
<form-bean name="testForm" type="TestForm" />
</form-beans>
<!-- ==================== Global Exception Definitions ============= -->
<global-exceptions>
</global-exceptions>
<!-- ===================== Global Forward Definitions ============== -->
<global-forwards>

</global-forwards>
<!-- ===================== Action Mapping Definitions ============== -->
<action-mappings>
<action path="/prepareLogic"
type="action.PrepareLogicAction">
validate="true"
<forward name="success" path="/Logic.jsp" />
</action>
</action-mappings>
<!-- ===================== Message Resources Definitions ============== -->
<message-resources parameter="ApplicationResources" />
<!-- ===================== plug-in Definitions ============== -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" property="pathnames" />
</plug-in>
</struts-config>

帮你整理下
leipub 2005-07-18
  • 打赏
  • 举报
回复
照我这样写
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" property="pathnames" />
</plug-in>
leipub 2005-07-18
  • 打赏
  • 举报
回复
一个是在plug-in里面配置
还有就是在action-mapping 里面设置validate="true"
bisliu 2005-07-18
  • 打赏
  • 举报
回复
struts-config.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean name="testForm" type="TestForm" />
</form-beans>
<global-forwards>
</global-forwards>
<action-mappings>
<action path="/prepareLogic" type="action.PrepareLogicAction">
<forward name="success" path="/Logic.jsp" />
</action>
</action-mappings>
<message-resources parameter="ApplicationResources" />
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
<set-property property="definitions-debug" value="2" />
<set-property property="definitions-parser-details" value="2" />
<set-property property="definitions-parser-validate" value="true" />
</plug-in>
</struts-config>
是不是应该加上
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
这样一段?jsp页面的taglib都有写了
liuquanyi 2005-07-18
  • 打赏
  • 举报
回复
是struts!
leipub 2005-07-18
  • 打赏
  • 举报
回复
还有感觉你的构架很乱
有的地方用了Struts有的地方又没用
bisliu 2005-07-18
  • 打赏
  • 举报
回复
对啊,我的struts-config.xml中确实没有validator那个配置,原来是这样啊,我试试。。。
leipub 2005-07-18
  • 打赏
  • 举报
回复
还有你的jsp有
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>吗
leipub 2005-07-18
  • 打赏
  • 举报
回复
应该是你的struts里面的validator验证没配置
把你的Struts-config.xml贴出来
bisliu 2005-07-18
  • 打赏
  • 举报
回复
我现在在jsp里面改用以下方式显示错误信息
<html:messages id="error" property="<%=ActionErrors.GLOBAL_ERROR%>">
<bean:write name="error"/>
</html:messages>
但是会报
javax.servlet.jsp.JspException: Cannot find bean error in any scope
这是我从其他例子中抄过来的,那边是没问题,可以正常显示,也没找到这个bean是在哪定义的,为什么搬过来就不行了?这个bean到底是个什么?需要怎么定义?
bisliu 2005-07-15
  • 打赏
  • 举报
回复
ApplicationResources.properties中有
error.test=this is a test!
fengyun1314 2005-07-15
  • 打赏
  • 举报
回复
ApplicationResources文件里面有没有那个error.test的属性??
bisliu 2005-07-15
  • 打赏
  • 举报
回复
web.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>customerweb</display-name>
<context-param>
<param-name>weblogic.httpd.inputCharset./*</param-name>
<param-value>GBK</param-value>
</context-param>
<context-param>
<param-name>ConfigFilePath</param-name>
<param-value>config_web.xml</param-value>
</context-param>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
</web-app>
加载更多回复(8)

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧