新聞中心
小編給大家分享一下ajax提交到j(luò)ava后臺(tái)實(shí)現(xiàn)處理數(shù)據(jù)的方法是什么,希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去探討吧!
創(chuàng)新互聯(lián)公司是一家從事企業(yè)網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、行業(yè)門(mén)戶網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)制作的專(zhuān)業(yè)網(wǎng)站建設(shè)公司,擁有經(jīng)驗(yàn)豐富的網(wǎng)站建設(shè)工程師和網(wǎng)頁(yè)設(shè)計(jì)人員,具備各種規(guī)模與類(lèi)型網(wǎng)站建設(shè)的實(shí)力,在網(wǎng)站建設(shè)領(lǐng)域樹(shù)立了自己獨(dú)特的設(shè)計(jì)風(fēng)格。自公司成立以來(lái)曾獨(dú)立設(shè)計(jì)制作的站點(diǎn)千余家。
環(huán)境:eclipse+struts
要實(shí)現(xiàn)的效果:點(diǎn)擊按鈕提交數(shù)據(jù)到后臺(tái)之后回到前臺(tái)顯示出來(lái)數(shù)據(jù)
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>Insert title here
struts.xml
index.jsp
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; } }
看完了這篇文章,相信你對(duì)ajax提交到j(luò)ava后臺(tái)實(shí)現(xiàn)處理數(shù)據(jù)的方法是什么有了一定的了解,想了解更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
網(wǎng)頁(yè)題目:ajax提交到j(luò)ava后臺(tái)實(shí)現(xiàn)處理數(shù)據(jù)的方法是什么
瀏覽地址:http://ef60e0e.cn/article/pespdc.html