老师,为什么我手机有吧null打印出来

来源:1-8 EL表达式输出

慕仙8246817

2020-05-16 10:31:21

<h1>姓名:${student.name }</h1>

<h2>手机: ${student.mobile}</h2>

<h2>成绩:${ grade }</h2>



protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

Student s=new Student();

s.setName("陈");

s.setMobile("NULL");

String grade="A";

request.setAttribute("grade", "C");

request.getServletContext().setAttribute("grade", "D");

HttpSession session=request.getSession();

session.setAttribute("student", s);

session.setAttribute("grade", grade);

// request.setAttribute("student", s);

// request.setAttribute("grade", grade);

request.getRequestDispatcher("/el_info.jsp").forward(request, response);

}


private String name;

private String mobile;

public String getName() {

return name;

}

public void setName(String name) {

this.name=name;

}

public String getMobile() {

return mobile;

}

public void setMobile(String mobile) {

this.mobile=mobile;

}

  http://img.mukewang.com/climg/5ebf50740921a63602900228.jpg

写回答

1回答

好帮手慕阿园

2020-05-16

同学你好,因为同学的null被引号引起来了,程序把它当做字符串来处理了,同学把引号去掉,并且把NULL改为小写的就可以了

如下图所示

http://img.mukewang.com/climg/5ebf892b090045e203640116.jpg

如果我的回答解决了你的疑惑,请采纳!祝学习愉快!

0

0 学习 · 9666 问题

查看课程