dwr 실례
1、 dwr jar dwr.jar
2、 web , dream, jar lib
3、 web.xml, :
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<!-- dwr -->
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
4、 Java :
package com.main;
public class Check {
public boolean check(String name,String password){
if(name.endsWith("123") && password.endsWith("123"))
return true;
else
return false;
}
}
5、 dwr.xml, Java , :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 3.0//EN" "http://getahead.org/dwr/dwr30.dtd">
<dwr>
<allow>
<create creator="new" javascript="Check"><!-- javascrit ,dwr Check.js, js Check Check -->
<param name="class" value="com.main.Check"></param>
</create>
<create creator="new" javascript="Hello">
<param name="class" value="com.main.Hello"></param>
</create>
</allow>
</dwr>
6、 jsp , :
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>DWR </title>
<!-- dwr js -->
<script type="text/javascript" src="/dream/dwr/engine.js"></script>
<script type="text/javascript" src="/dream/dwr/util.js"></script>
<!-- -->
<!-- dwr javascript , dwr js -->
<script type="text/javascript" src="/dream/dwr/interface/Check.js"></script>
<script type="text/javascript">
function login(){
var name = dwr.util.getValue("name");
var password = dwr.util.getValue("password");
Check.check(name,password,function (ok){// ok Check check(String name,String password)
if(ok==true){
document.getElementById("loginDiv").style.visibility = "hidden";
document.getElementById("resultDiv").style.visibility = "visible";
document.getElementById("resultDiv").innerHTML = "<font color=red size=8> , !</font>";
}else{
document.getElementById("resultDiv").style.visibility = "visible";
document.getElementById("resultDiv").innerHTML = "<font color=red size=8> !</font>";
}
});
}
</script>
</head>
<body>
<div id="resultDiv" style="border-color: green;border-width: 1px;border-style: outset;width: 50%;visibility: hidden;">
</div>
<div id="loginDiv" style="visibility: visible;">
:<input type="text" name="name" id="name">
<br><br>
:<input type="password" name="password" id="password">
<br><br>
<input type="button" value=" " onclick="login()">
</div>
</body>
</html>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Is Eclipse IDE dying?In 2014 the Eclipse IDE is the leading development environment for Java with a market share of approximately 65%. but ac...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.