Implementation of Data Processing after ajax is submitted to the java background, ajaxjava

Source: Internet
Author: User

Implementation of Data Processing after ajax is submitted to the java background, ajaxjava

Environment: eclipse + struts

Effect:Click the button to submit the data to the background and return to the foreground to display the data.

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"> 

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;   } } 

After the above ajax is submitted to the java background, the implementation of data processing is all the content that I have shared with you. I hope to give you a reference and support for the customer's house.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.