所以在我的Servlet中我有以下内容:
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("text/html");
req.setAttribute("colNames","ka");
req.setAttribute("items", new String[]{});
//System.out.println(req.getAttribute("colNames"));
req.getRequestDispatcher("/index.jsp").forward(req,resp);
}
我的Servlet:
NewGem OrderInfo${col} |
${value} |
web.xml中:
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
org.springframework.web.context.ContextLoaderListener
EntityDumpServlet
dump
EntityDumpServlet
com.jpmorgan.d1.ptg.web.EntityDumpServlet
1
EntityDumpServlet
/dump
所以我只是运行get,只有这个servlet没有别的.
我知道我应该使用JSTL而且我是,但这是我检查它不是JSTL问题的方式,而是一些java问题.有人有主意吗?
PS:如果我只做我得到org.apache.catalina.connector.RequestFacade@58c3fbeb所以问题不在于没有将结果转换为String.
如果我在servlet System.out.println(req)上做;我得到org.apache.catalina.connector.RequestFacade@4ac37ce2,这意味着由于某种原因,传递和接收的请求是不同的?
结果:事实证明,由于某种原因,IDE正在做一些奇怪的事情,并在转发中引入了这个问题.当我在tomcat上使用maven编译的WAR文件部署它时,它运行正常.