java getattribute为空_java – JSP getAttribute()返回null

所以在我的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文件部署它时,它运行正常.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值