struts2+ajax+jquery
ajax交互
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>Insert title here
action:
AjaxAction.java
public class AjaxAction extends ActionSupport { private String word; public String getWord() { return word; } public void setWord(String word) { this.word = word; } public InputStream getContentStream() throws Exception { return new ByteArrayInputStream("你好事假".getBytes("utf-8")); } @Override public String execute() throws Exception { System.out.println("AjaxAction.execute()" + word); return SUCCESS; } }
JsonAction.java
public class AjaxAction extends ActionSupport { private String word; public String getWord() { return word; } public void setWord(String word) { this.word = word; } public InputStream getContentStream() throws Exception { return new ByteArrayInputStream("你好事假".getBytes("utf-8")); } @Override public String execute() throws Exception { System.out.println("AjaxAction.execute()" + word); return SUCCESS; } }
JsonAction.java
public class AjaxAction extends ActionSupport { private String word; public String getWord() { return word; } public void setWord(String word) { this.word = word; } public InputStream getContentStream() throws Exception { return new ByteArrayInputStream("你好事假".getBytes("utf-8")); } @Override public String execute() throws Exception { System.out.println("AjaxAction.execute()" + word); return SUCCESS; } }
stryts.xml
contentStream utf-8 message
posted @ 2017-05-31 11:15 阅读( ...) 评论( ...)