不刷新页面,不需要Jquery等等
JS代码
var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open("Get","demo.do?status=c&name="+name,false);
http.send();
alert(http.responseText);
http.open("Get","demo.do?status=c&name="+name,false);
http.send();
alert(http.responseText);
Java代码
public class DemoAction
extends DispatchAction {
public ActionForward c(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception {
String name= new String(request.getParameter("name").getBytes("ISO-8859-1"), "gbk");
request.setAttribute("ch","aaa");
return (mapping.findForward("ch"));
}
}
extends DispatchAction {
public ActionForward c(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception {
String name= new String(request.getParameter("name").getBytes("ISO-8859-1"), "gbk");
request.setAttribute("ch","aaa");
return (mapping.findForward("ch"));
}
}
struts.xml
<action type="com.DemoAction" parameter="status" path="/demo" >
<forward name="ch" path="/ch.jsp" />
</action>
<forward name="ch" path="/ch.jsp" />
</action>
ch.jsp代码
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %><%String ch=(String)request.getAttribute("ch");