你要搞明白服务器端脚本和客户端脚本之间的区别

解决方案 »

  1.   

    如果非得这样操作,不是不行,但这样不太好,违背了MVC通过dwr能轻松实现:import javax.servlet.http.HttpSession;import org.directwebremoting.WebContext;
    import org.directwebremoting.WebContextFactory;在java类中定义方法:setValueToSession(String value)
    {
      HttpSession session = null;  WebContext ctx = WebContextFactory.get();

      session = ctx.getHttpServletRequest().getSession();
      
      session.setAttribute("name","123")}