struts中reset无效怎么办?

happybull 2007-06-05 10:52:02
struts中reset无效怎么办?
...全文
354 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
happybull 2007-06-07
  • 打赏
  • 举报
回复
谢谢 解决了 我在form里实现的!
CodeFans 2007-06-07
  • 打赏
  • 举报
回复
首先需要明白的reset的含义,在ie里面的reset的意思就是说,
可以帮你把form里面的控件值设置成初始值,而不是设置成空,
出错后,你的控件里面本来是有值的。所以你reset不能设置他们
为空。
比如:name里面你设置了“csdn”, 出错后,如果你没有清空name的值
那么返回后, 控件的初始值就是“csdn”, 然后你修改为“csdn1234”
,那么你reset应该就reset成“csdn”。

所以你要想置空, 1, 自己也脚本。或者 2, 在action里面设置form的值为空。
happybull 2007-06-05
  • 打赏
  • 举报
回复
<%@ page language="java" pageEncoding="GBK"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>


<html:html lang="true">
<head>
<html:base />
<title>login.jsp</title>
</head>
<body>
<h2 align="center">登陆页面</h2>
<br><hr>
<html:errors/>
<html:form action="login.do" method="post">
<table border="1" align="center">
<tr>
<td colspan="2" align="center">用户登陆</td>
</tr>
<tr>
<td align="left">用户名:
</td>
<td>
<html:text property="name"></html:text>
</td>
</tr>
<tr>
<td align="center">密码:
</td>
<td>
<html:password property="password"></html:password>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<html:submit value="提交"></html:submit>
<html:reset value="重置"></html:reset>
</td>
</tr>
</table>
</html:form>
</body>
</html:html>
提交菜单后如果错误的话会再回到这登陆页面,但是这个时候点reset就没作用了!怎么回事?
happybull 2007-06-05
  • 打赏
  • 举报
回复
form里的reset方法如何写?我只知道在reset里面初始化。如果把初始化name,password都为空,好像还是不行!
li_d_s 2007-06-05
  • 打赏
  • 举报
回复
form的reset方法没写?
likgui 2007-06-05
  • 打赏
  • 举报
回复
关注

50,679

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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