日期:2014-05-19 浏览次数:20725 次
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>dwr_invoker</servlet-name> <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>dwr_invoker</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping> </web-app>
<?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="UserService"> <param name="class" value="com.accp.service.UserService"></param> <include method="login"/> </create> </allow> </dwr>
package com.accp.service; public class UserService { public boolean login(String username,String password){ if(username.equals("zjy") && password.equals("300")){ return true; } return false; } }
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>DWR page</title> <script type="text/javascript" src="<%=path%>/dwr/interface/UserService.js"></script> <script type="text/javascript" src="<%=path%>/dwr/engine.js"></script> <script type="text/javascript" src="<%=path%>/dwr/util.js"></script> <script type="text/javascript"> function hellodwr(){ var username = document.getElementById("username").value; var password = document.getElementById("password").value; alert(password); UserService.login(username,password,hellocallbac