struts标签问题,急,急,急,在线等

scottwj 2005-03-17 03:15:54
从action到页面
action里为:

request.setAttribute("list", list);

页面为:
<logic:iterate id="mes" name="list" type="com.dawnpro.test.dao.model.TUser">
<tr>
<td><div align="center"><bean:write name="mes" property="id" /></div></td>
<td><div align="center"><bean:write name="mes" property="password" /></div></td>
</tr>
</logic:iterate>

其中id为int,username为string

不要<bean:write name="mes" property="id" />正常

否则报错
javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE
......

javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE



...全文
133 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
scottwj 2005-03-17
  • 打赏
  • 举报
回复
同意无心最后一句话
scottwj 2005-03-17
  • 打赏
  • 举报
回复
回复人: zgdhj95(love tiffany)
我这里那里有什么bean呀?
直接是在页面上,现在不谈什么bean,和什么配置.
<%
int test=1;
request.setAttribute("test1",new Integer(test));
%>
<bean:write format="#" name="test1"/>

lmcctvjava 2005-03-17
  • 打赏
  • 举报
回复
呵呵 实际上 struts的内部机制在 bean write的时候 调用了toString()方法的
eversnow 2005-03-17
  • 打赏
  • 举报
回复
我记得对于对象中的int类型的field用bean:write是没有问题的呀,你的struts是什么版本阿?还有对于上
new Integer(test)和你开头说的问题有关系么?一个是int,一个是Integer?
zgdhj95 2005-03-17
  • 打赏
  • 举报
回复
我这什么都不加,直接就显示得啊,你哪怎么这么麻烦!所以我才问你bean设置是否有问题
scottwj 2005-03-17
  • 打赏
  • 举报
回复
要加format对类型进行格式化
<%
int test=1;
request.setAttribute("test1",new Integer(test));
%>
<bean:write format="#" name="test1"/>

lmcctvjava 2005-03-17
  • 打赏
  • 举报
回复
怎么会呢 ~~~~是哪里的问题 怎么解决的 说来听听
scottwj 2005-03-17
  • 打赏
  • 举报
回复
哈哈,楼上的,问题已经解决,是可以显示int型的.
lmcctvjava 2005-03-17
  • 打赏
  • 举报
回复
<bean:write>只能打印出string类型来 int是显示不出来的!建议你改bean中的id属性
scottwj 2005-03-17
  • 打赏
  • 举报
回复
怎么就没有人能回答一下啊
scottwj 2005-03-17
  • 打赏
  • 举报
回复
跟你们都说了id是int型.
这样吧,
<%
int test=1;
request.setAttribute("test1",new Integer(test));
%>
<bean:write name="test1"/>
这样写就报错,以下的写发就不报错
<%
String test="1";
request.setAttribute("test1",test);
%>
<bean:write name="test1"/>

wenchaohu213 2005-03-17
  • 打赏
  • 举报
回复
在开始的时候

看看你的ID的类型定义是否匹配。
querlang 2005-03-17
  • 打赏
  • 举报
回复
看看你的hbm文件中的id属性
scottwj 2005-03-17
  • 打赏
  • 举报
回复
<bean:write name="mes" property="id" />
这里面的值是不是只能由string赋进去,其它类型都报错
scottwj 2005-03-17
  • 打赏
  • 举报
回复
这些肯定是都有的,现在的问题是id不能为int,为string就正常.
我想问问是不是<bean:write name="mes" property="id" />
这里面的值不能由integer赋进去的
zgdhj95 2005-03-17
  • 打赏
  • 举报
回复
对象类的set get方法都设置了么

67,514

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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