struts2 学习拾掇
来源:互联网 发布:java hashset用法 编辑:程序博客网 时间:2024/04/29 05:52
HttpSession session = ServletActionContext.getRequest().getSession();SelectSql sel = new SelectSql();System.out.println(sel.selectNewsAll().size());session.setAttribute("newslist", sel.selectNewsAll());return SUCCESS;
将list<News>保存进jsp中 ,如何从jsp中取出来 ,如下:
<s:iterator value="#session.newslist" status="statu" id="item">
<s:property value="title" /><s:property value="content" />
</s:iterator>
进入一个页面直接调用action
放在《body》下
<s:action name="allnews" executeResult="false"></s:action>
myeclipse jsp快速注释 ctrl+shift+c
struts2 表单验证
<form action="houtai/userLogin" name="loginForm" method="post"> <td width="50%" valign="bottom"><s:textfield name="user.userName" id="username" size="20" maxlength="20"/></td> </tr> <tr> <td> </td> <td valign="bottom"><s:password name="user.password" size="22" maxlength="20"/></td> </tr><area shape="rect" coords="280,8,335,34" href="#" onClick="return checkForm();"> <area shape="rect" coords="357,8,413,35" href="#" onClick="return reset();"></map></form> <script type="text/javascript">function checkForm() { var username=document.getElementById("username").value; if(username=="" ){ alert("用户名不能为空!"); document.getElementById("username").focus(); return false; } if(username.length<4 || username.length>10){ alert("用户名长度在4到10之间"); return false; }else{ document.loginForm.submit(); }}
struts2 namespace 配置 要以"/" 开头,否则报错 无法找到action mapping
数据库出现乱码 ,在连接时指定链接字符
jdbc:mysql://localhost:3306/test?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
struts2 比如要删除一个结果集,如删除一条新闻,根据<a href="delNews?newId=<s:property value='newId'/>"
onclick="return confirm('确认删除?')">删除</a></td>
来传入newId给action 删除,那么传入action的方式有
String param = ServletActionContext.getRequest().getParameter("newId");
<s:textfield name="news.title" value="<s:property value="request.news.title" >"/> 无法嵌套struts2 标签,会报错
正确的做法是,直接赋值
<s:textfield name="news.title" value="%{#request.news.title}" />
- struts2 学习拾掇
- 学习拾掇
- 重新拾掇...
- oracle 拾掇
- 拾掇快乐
- mangos 之拾掇
- 拾掇起来的年华
- Oracle碎片拾掇全面解析
- 拾掇起来的年华(2)
- [Struts2]Struts2学习总结
- Struts2 学习
- Struts2学习
- 学习struts2
- 学习struts2
- 学习struts2
- 学习Struts2
- Struts2学习
- struts2学习
- A. Magic Numbers
- c++ 100例编程-004
- spring配置文件详解
- sdut1500 Message Flood
- 2013-6-25备份
- struts2 学习拾掇
- 图之图的广度优先遍历
- 程序员必知:平凡而又神奇的贝叶斯方法
- jdbc查询数据库
- 如何制作/输入 英语/美语音标
- [OpenCV2]使用指针遍历图像
- oracle 拾掇
- 一个socket的基础例子
- Spring攻略笔记-4 Bean的作用域