不刷新页面,不需要Jquery等等

 

JS代码

var http = new ActiveXObject("Microsoft.XMLHTTP");
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"));
  }
}
 
struts.xml
  <action type="com.DemoAction" parameter="status" path="/demo" >
    <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");

 

 

 

 

 

 

 

相关文章:

  • 2022-02-08
  • 2022-02-08
  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-22
  • 2022-12-23
  • 2021-06-16
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案