使用的一个问题

lywei123 2004-04-28 03:35:28
<%
{
java.util.ArrayList list = new java.util.ArrayList();
list.add("First");
list.add("Second");
list.add("Third");
list.add("Fourth");
list.add("Fifth");
pageContext.setAttribute("list", list, PageContext.PAGE_SCOPE);
}
%>
<ol>
<logic:iterate id="item" name="list" indexId="index1">
<li><bean:write name="item"/></li>
</logic:iterate>
</ol>
这样可以正确显示

<ol>
<logic:iterate id="item" name="list" indexId="index1">
<li><bean:write name="item"/><bean:write name="index1"/></li>
</logic:iterate>
</ol>
改成这样就不行了,提示:
javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE

另外<iterate>不会只支持ArrayList吧
<%
{
int intArray[] = new int[]
{ 0, 10, 20, 30, 40 };
pageContext.setAttribute("intArray", intArray, PageContext.PAGE_SCOPE);
}
%>
<ol>
<logic:iterate id="item" name="intArray" indexId="index1">
<li><bean:write name="item"/></li>
</logic:iterate>
</ol>
提示:
javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE

初学struts,请高手指教
...全文
166 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lywei123 2004-04-29
  • 打赏
  • 举报
回复
谢谢楼上,在struts-config.xml中指定一个ApplicationResources.properties就可以运行了,不过发现一个问题,指定的ApplicationResources.properties即使不存在,也可以正常运行,困惑,这个文件起一个什么作用呢?得到答案马上结帖
xunyiren 2004-04-28
  • 打赏
  • 举报
回复
你的程序我测试没有任何问题!!请确保应用程序资源的完整性,%WEB-ROOT%\WEB-INF下要有struts-config.xml和web.xml,WEB-INF\classes下或其子目录下要有ApplicationResources.properties文件
judyhui7612 2004-04-28
  • 打赏
  • 举报
回复
javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE

這個錯誤應該是bean:message 的錯誤吧,你是不是在頁面中用了bean:message標簽,或者在struts-cofig.xml 配置了資源文件
lywei123 2004-04-28
  • 打赏
  • 举报
回复
indexId
The name of a page scope JSP bean that will contain the current index of the collection on each iteration.

jakarta上是这么说的,可是这个属性应该怎么用呢?
顽皮小熊 2004-04-28
  • 打赏
  • 举报
回复
大哥 你网页里用的当然是映射了,indexId是什么?是映射的名称吗?
id才是你描述文件里用到的标识!错了勿怪!

81,122

社区成员

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

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