为什么我的标签名不会加载???

来源:2-13 自由编程

大吉他

2021-01-27 10:56:37

public class TwoServlet extends HttpServlet {

@Override

public void service(HttpServletRequest request,HttpServletResponse response) throws IOException {

String first=request.getParameter("first");

String two=request.getParameter("two");

int n=Integer.parseInt(first)+Integer.parseInt(two);

PrintWriter out=response.getWriter();

out.println("<h2>Calculation results="+n+"</h2>");

}

}

http://img.mukewang.com/climg/6010d65709ab7adb09990232.jpg

写回答

1回答

好帮手慕小脸

2021-01-27

同学你好,同学是指如下图一未加载还是<h2>标签被显示呢?

图一:

http://img.mukewang.com/climg/6010dbbc093b0d0902350053.jpg

如果是,是因为同学并未输出,这里添加如下代码即可:

http://img.mukewang.com/climg/6010e1200945ad6304930058.jpg

图二:

http://img.mukewang.com/climg/6010dbed09292c1008760140.jpg

这里之所以显示<h2>是因为没有h1标签,浏览器不能够正常的解析其它的h标签(h2-h5)。所以使用h2-h5标签,输出了字符串,修改代码如下所示:

http://img.mukewang.com/climg/6010e11609f0b96606020125.jpg

http://img.mukewang.com/climg/6010e0dc09d4ef7e04480193.jpg

祝学习愉快~

0

0 学习 · 16556 问题

查看课程