index.jsp
上传用户:sz_mindeo
上传日期:2015-07-22
资源大小:913k
文件大小:2k
- <%@ page language="java" pageEncoding="GB18030"%>
- <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
- <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
-
- <html>
- <head>
- <script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'> </script>
- <script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'> </script>
- <script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/myuserDAO.js'> </script>
- <script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/myuser.js'> </script>
- <!-- 在dwr.xml中定义了名为Demo的JavaScript -->
-
- <script type="text/javascript">
- function check()
- {
- var name = dwr.util.getValue("userName");
-
- myuser = { userName:name};
- myuserDAO.checkName
- (myuser,function(data)
- {
- if(data=="用户名有效")
- {
- document.loginForm.password.focus();
- }
- else
- {
- document.loginForm.userName.value="";
- document.loginForm.userName.focus();
- }
- dwr.util.setValue("nameMessage" ,data);
- }
- );
- }
- /* DWR是异步的,所以浏览器不会因为我们等待在后台的HTTP请求返回而阻塞在那里。所以我们要指定一个callback函数,在请求返回的时候自动调用。这里的function(data)就是这个callback函数*/
- /* dwr.util提供了一些如getValue和setValue的函数方便我们操作页面元素 */
- </script>
- </head>
- <body>
- <html:form action="/login.do" method="post">
- userName : <html:text property="userName" onblur="check();"/><span id="nameMessage" style="width:200px ; height:20px;"></span><br/>
- <br><br> password:<html:password property="password"/><html:errors property="password"/><br/>
- <html:submit/><html:cancel/>
- </html:form>
- <br>
- <html:link page="/register.jsp">我去注册</html:link>
- </body>
- </html>