Detailed example of how to process data after ajax is submitted to the java background

小云云
Release: 2023-03-18 13:38:01
Original
1872 people have browsed it

This article mainly brings you an implementation of processing data after ajax is submitted to the java background. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor to take a look, I hope it can help everyone.

Environment: eclipse+struts

The effect to be achieved: click the button to submit the data to the background and then return to the foreground to display the data

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>     Insert title here 
    

Copy after login

struts.xml

 index.jsp 
Copy after login

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; } }
Copy after login

Related recommendations:

php transaction processing data sample code

Detailed introduction to database processing

PHP transaction processing data implementation code_PHP tutorial

The above is the detailed content of Detailed example of how to process data after ajax is submitted to the java background. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!