校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > ajax提交到j(luò)ava后臺之后處理數(shù)據(jù)的實(shí)現(xiàn)

ajax提交到j(luò)ava后臺之后處理數(shù)據(jù)的實(shí)現(xiàn)

熱門標(biāo)簽:電銷機(jī)器人 長春 中國地圖標(biāo)注不明確情況介紹表 立陶宛地圖標(biāo)注 東平縣地圖標(biāo)注app 上海企業(yè)外呼系統(tǒng)價錢 地圖標(biāo)注推銷坑人 大眾點(diǎn)評400電話怎么申請 河間市地圖標(biāo)注app 怎樣在地圖標(biāo)注文字

環(huán)境:eclipse+struts

要實(shí)現(xiàn)的效果:點(diǎn)擊按鈕提交數(shù)據(jù)到后臺之后回到前臺顯示出來數(shù)據(jù)

index.jsp

%@ page language="java" contentType="text/html; charset=UTF-8" 
  pageEncoding="UTF-8"%> 
!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
html> 
head> 
meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
title>Insert title here/title> 
/head> 
body> 
input type="text" id="userinput"> 
input type="button" id="submit"> 
div id="msg">/div> 
/body> 
script type="text/javascript" src="jquery-2.1.0.js">/script> 
script type="text/javascript"> 
window.onload = function() { 
  document.getElementById("submit").onclick = test; 
} 
function test(){ 
  var userinput = document.getElementById("userinput"); 
  $.post("http://localhost:8080/TestSpring/TestAction",{username:userinput.value}, 
  function(data, textStatus){ 
    document.getElementById("msg").innerHTML = data; 
  });  
} 
/script> 
/html> 

 struts.xml

action name="TestAction" class="com.action.Test"> 
  result>index.jsp/result> 
/action> 

Test.java

package com.action; 
 
import java.io.PrintWriter; 
import java.util.Map; 
 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
 
import org.apache.struts2.ServletActionContext; 
 
import com.opensymphony.xwork2.ActionContext; 
import com.opensymphony.xwork2.ActionSupport; 
 
public class Test extends ActionSupport { 
  @Override 
  public String execute() throws Exception { 
    // TODO Auto-generated method stub 
    HttpServletRequest request = org.apache.struts2.ServletActionContext.getRequest(); 
    HttpServletResponse response = ServletActionContext.getResponse(); 
    request.setCharacterEncoding("utf-8"); 
    response.setCharacterEncoding("utf-8"); 
    PrintWriter out = response.getWriter(); 
    out.write(request.getParameter("username")); 
    out.flush(); 
    out.close(); 
    return SUCCESS; 
  } 
} 

以上這篇ajax提交到j(luò)ava后臺之后處理數(shù)據(jù)的實(shí)現(xiàn)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • jQuery+datatables插件實(shí)現(xiàn)ajax加載數(shù)據(jù)與增刪改查功能示例
  • MVC+jQuery.Ajax異步實(shí)現(xiàn)增刪改查和分頁
  • jQuery的Ajax接收java返回?cái)?shù)據(jù)方法
  • ajax java 實(shí)現(xiàn)自動完成功能
  • AJAX+JAVA用戶登陸注冊驗(yàn)證的實(shí)現(xiàn)代碼
  • 詳解Java Ajax jsonp 跨域請求
  • Java使用Ajax實(shí)現(xiàn)跨域上傳圖片功能
  • Javaweb使用cors完成跨域ajax數(shù)據(jù)交互
  • 深入Ajax代理的Java Servlet的實(shí)現(xiàn)詳解
  • 在Java的Struts中判斷是否調(diào)用AJAX及用攔截器對其優(yōu)化
  • AJAX實(shí)現(xiàn)數(shù)據(jù)的增刪改查操作詳解【java后臺】

標(biāo)簽:四川 銅川 益陽 營口 內(nèi)江 玉樹 本溪 遼寧

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ajax提交到j(luò)ava后臺之后處理數(shù)據(jù)的實(shí)現(xiàn)》,本文關(guān)鍵詞  ajax,提,交到,java,后臺,之后,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ajax提交到j(luò)ava后臺之后處理數(shù)據(jù)的實(shí)現(xiàn)》相關(guān)的同類信息!
  • 本頁收集關(guān)于ajax提交到j(luò)ava后臺之后處理數(shù)據(jù)的實(shí)現(xiàn)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 常州市| 南召县| 松原市| 甘泉县| 玉环县| 柘荣县| 荆门市| 阳信县| 玛多县| 元氏县| 中宁县| 平定县| 甘南县| 昌图县| 涞水县| 紫金县| 通道| 洪湖市| 张家港市| 岑巩县| 深泽县| 大冶市| 澄城县| 宁河县| 高清| 东城区| 民乐县| 顺平县| 宁城县| 泰顺县| 大荔县| 修文县| 天台县| 大丰市| 阿城市| 江华| 石棉县| 安国市| 准格尔旗| 基隆市| 柏乡县|