新手提问:如何通过servlet将网页的一部分文字改变成其他的文字
用servlet的POST方法。
求代码怎么写?

解决方案 »

  1.   

    html:
    <div id='div1'></div>//执行ajax请求代码
    $.get('xxxServlet',function(data){
    $('#div1').html(data);
    });servlet:doPost(){
    out.print('hello');
    }用ajax来实现,上面是jquery版的,大致这个样子,懒得写了
      

  2.   

    0.0..我刚刚学的jspajax..不懂+没听过啊不过还是谢啦,ajax我回头好好学习下。
      

  3.   

    刚才我找到了那个代码了。我们之前考试上给的。
    拿来一起分享下~
    html:
    <%
        String msg = (String)request.getAttribute("msg");
        if(msg == null) { 
    %>
    <div align="center"><strong><font color="#FFFFFF">请输入</font><font color="#FFFFFF"></font></div>
    <%
        }
        else {
        out.print(msg);
        }
    %>servlet:
    request.setAttribute("msg", "<font color='red'>XXXX</font>");
    request.getRequestDispatcher("/jsp/login.jsp").forward(request, response);