我需要一个来自我的 servlet 的双值来标记我的 JSP。我的 doGet() 正在发回带有 ArrayList 值的格式化 HTML 表,所以在我开始工作后,我决定处理这部分。
小服务程序:
//获取我需要的表的代码
//Send back the result, this all works good
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(returnAsHTML.toString());
我添加的内容是为了尝试获得双倍价值
//Send back the result
double test = 20;
request.setAttribute("Test",test);
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(returnAsHTML.toString());
getServletContext().getRequestDispatcher("index.jsp").forward(request,response);
在 JSP 中:
<!-- This variable is unresolved -->
<small>Test : ${Test}</small>
转发似乎使整个聚会崩溃。我是 JSP 的新手,我确定我遗漏了一些小东西。我需要把 response.getWriter() 的东西放在那里,它会得到很多我需要的信息。现在我只是不知道如何获得我需要的 double 值,因为它们将显示在页面的完全不同的部分。