• 大小: 4.36MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-20
  • 语言: Java
  • 标签:

资源简介

网上找了很多,结果都运行不了,不齐全,想找一个ajax实现用户名注册的实例很难,今天自己写了一个项目,可以运行,希望对你有帮助

资源截图

代码片段和文件信息

package com.hisoft.jqt.action;   
  
import java.io.IOException;   
import java.io.PrintWriter;   
import java.util.HashMap;   
import java.util.Map;   
  
import javax.servlet.http.HttpServletRequest;   
import javax.servlet.http.HttpServletResponse;   
  
import net.sf.json.JSONobject;   
  
import org.apache.struts2.ServletActionContext;   
  
   
import com.opensymphony.xwork2.ActionContext;   
import com.opensymphony.xwork2.ActionSupport;
  
@SuppressWarnings(“serial“)
public class TestAction extends ActionSupport{  
  
    HttpServletRequest hsr; 
    
    String result;   
       
    public HttpServletRequest getHsr() {   
        return hsr;   
    }   
  
    public void setHsr(HttpServletRequest hsr) {   
        this.hsr = hsr;   
    }   
  
    public String getResult() {   
        return result;   
    }   
  
    public void setResult(String result) {   
        this.result = result;   
    }   
  
    public String test() throws IOException{   
      
     Map map = new HashMap();   
           
        ActionContext ac = ActionContext.getContext();   
        HttpServletRequest req = (HttpServletRequest)ac.get(ServletActionContext.HTTP_REQUEST);   
        HttpServletResponse res = (HttpServletResponse)ac.get(ServletActionContext.HTTP_RESPONSE);   
        String userName = req.getParameter(“userName“);   
        map.put(“userName“ userName);   
       
        res.setContentType(“text/html;charset=UTF-8“);   
        
        PrintWriter w = res.getWriter();   
       
        if(“jack“.equals(userName)){   
            JSONobject jo = JSONobject.fromobject(map);         
            this.result = jo.toString();      
            w.println(“可以使用“);   
        }else{   
            w.println(“不可以使用“);   
        }   
        w.close();   
        
        return “success“;   
    }       
}  

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-04-09 10:33  testAjax\
     文件        1374  2013-04-09 10:34  testAjax\.classpath
     目录           0  2013-04-09 15:54  testAjax\.myeclipse\
     文件         297  2013-04-09 15:53  testAjax\.mymetadata
     文件        1751  2013-04-09 10:34  testAjax\.project
     目录           0  2013-04-09 10:34  testAjax\.settings\
     文件         500  2013-04-09 10:34  testAjax\.settings\.jsdtscope
     文件          97  2010-08-19 10:19  testAjax\.settings\org.eclipse.core.resources.prefs
     文件         629  2013-04-09 10:34  testAjax\.settings\org.eclipse.jdt.core.prefs
     文件         462  2013-04-09 10:33  testAjax\.settings\org.eclipse.wst.common.component
     文件         252  2013-04-09 10:34  testAjax\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2013-04-09 10:34  testAjax\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2013-04-09 10:34  testAjax\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2013-04-09 15:54  testAjax\WebRoot\
     目录           0  2013-04-09 10:33  testAjax\WebRoot\meta-INF\
     文件          39  2010-08-19 09:54  testAjax\WebRoot\meta-INF\MANIFEST.MF
     目录           0  2013-04-09 10:33  testAjax\WebRoot\WEB-INF\
     目录           0  2013-04-09 15:53  testAjax\WebRoot\WEB-INF\classes\
     目录           0  2013-04-09 15:53  testAjax\WebRoot\WEB-INF\classes\com\
     目录           0  2013-04-09 15:53  testAjax\WebRoot\WEB-INF\classes\com\hisoft\
     目录           0  2013-04-09 15:53  testAjax\WebRoot\WEB-INF\classes\com\hisoft\jqt\
     目录           0  2013-04-09 15:53  testAjax\WebRoot\WEB-INF\classes\com\hisoft\jqt\action\
     文件        2518  2013-04-09 15:53  testAjax\WebRoot\WEB-INF\classes\com\hisoft\jqt\action\TestAction.class
     文件         637  2010-08-13 18:45  testAjax\WebRoot\WEB-INF\classes\log4j.properties
     文件         279  2010-08-18 17:42  testAjax\WebRoot\WEB-INF\classes\struts.properties
     文件        1485  2010-08-19 10:10  testAjax\WebRoot\WEB-INF\classes\struts.xml
     目录           0  2013-04-09 10:33  testAjax\WebRoot\WEB-INF\lib\
     文件      188671  2010-08-19 09:55  testAjax\WebRoot\WEB-INF\lib\commons-beanutils.jar
     文件      571259  2010-08-19 09:55  testAjax\WebRoot\WEB-INF\lib\commons-collections.jar
     文件      243016  2010-08-19 09:55  testAjax\WebRoot\WEB-INF\lib\commons-lang.jar
     文件       38015  2010-08-19 09:55  testAjax\WebRoot\WEB-INF\lib\commons-logging-1.0.4.jar
............此处省略23个文件信息

评论

共有 条评论

相关资源