当前位置: 代码迷 >> Java Web开发 >> jsp留言板显示有关问题
  详细解决方案

jsp留言板显示有关问题

热度:154   发布时间:2016-04-17 01:06:12.0
jsp留言板显示问题
一开始进入留言板的时候内容显示不了,只有写留言之后返回到index.jsp才能显示所有的留言,感觉是action的问题,但是在struts.xml中加了update的action,问题还是没有解决··求解释!!!
struts.xml
XML code
<package name="person" namespace="/" extends="struts-default">                <action name="TbPerson" class="com.index.PersonAction" method="update">            <result name="success">/index.jsp</result>        </action>        <action name="hibernate1"  class="com.index.PersonAction" method="save">                    <result name="success">/index.jsp</result>            </action>

index.jsp
HTML code
<body>    <h1>留言板</h1>                <s:form action="TbPerson.action"  />                    <s:a href="taglibtest.jsp">写留言</s:a>        <hr/>        <s:a href="management.jsp">留言板管理</s:a>        <hr/>        <h1>留言:</h1>        <s:iterator value="#request.list" id="TbPerson">            <s:div>                <s:label value="姓名:"/>                <s:property value="name"/>            </s:div>            <s:div>                <s:label value="内容:"/>                <s:property value="msg"/>            </s:div>            <s:div>                <s:a href="deleteps.action?id=%{#TbPerson.id}" >删除</s:a>            </s:div>            <hr/>        </s:iterator>

Java code
public String update()throws Exception{        TbPerson person = new TbPerson();        person.setName(name);        person.setMsg(msg);        DBperson.update(person);                List<TbPerson> list=DBperson.ListAll();        HttpServletRequest request =ServletActionContext.getRequest();        request.setAttribute("list", list);  //保存数据                return SUCCESS;    }


------解决方案--------------------
你进留言板之前是有没有进入Action得到list啊
  相关解决方案