ssh,


 

//列表页面

public String listUI(){
userList = userService.findAll();
return "listUI";

}

这个东西 有个userList 此时 用的Struts框架 此时 userList 会自动放在栈顶 不用自己刻意放 自动 就放在了栈顶

 这时 在jsp 界面取值的时候 因为userList  在栈顶 所以 不用添加 #符号 直接写就行  就可以取到相应的值

<s:textfield name="user.name" cssClass="s_text" id="userName"  cssStyle="width:160px;"/>因为在userList  存放的是User的集合  

<s:iterator value="userList" status="st">
                            <tr <s:if test="#st.odd">bgcolor="f8f8f8"</s:if> >
                                <td align="center"><input type="checkbox" name="selectedRow" value="<s:property value='id'/>" /></td>
                                <td align="center"><s:property value="name"/></td>
                                <td align="center"><s:property value="account"/></td>
                                <td align="center"><s:property value="dept"/></td>
                                <td align="center"><s:property value="gender?'男':'女'"/></td>
                                <td align="center"><s:property value="email"/></td>

当把userList 放在迭代器中的时候。取出来的每一个 就是一个User 而且 会把User放在栈顶 这时候 取list中User的属性的时候 就也不用加上#了

 

在 struts 配置文件中 

 

 global  和 拦截器的位置不能 反过来 不然会报错(启动报错) 

Caused by: 元素类型为 "package" 的内容必须匹配 "(result-types?,interceptors?,default-interceptor-ref?,default-action-ref?,default-class-ref?,global-results?,global-exception-mappings?,action*)"。 这个错误 意思是你配置错了

位置顺序不对 因为 要先执行拦截器  然后是 action  上面的顺序就是 需要写的顺序不能 更改

 

 

 

 

 

 

 

 

 

 

 

 

相关内容

    暂无相关文章