下面一个是谷歌浏览器 上面一个就是eclipse的内部运行。不明白为什么一个可以一个不可以。
来源:2-5 自由编程
dobe001
2019-08-03 11:41:26

package com.ccc.pro;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ServletProj extends HttpServlet{
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String category=request.getParameter("category");
String html="<h2 style='color:blue'>"+category+"</h2>";
PrintWriter out=response.getWriter();
out.println(html);
}
}<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>ServletProj</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>pro</servlet-name> <servlet-class>com.ccc.pro.ServletProj</servlet-class> </servlet> <servlet-mapping> <servlet-name>pro</servlet-name> <url-pattern>/ShopServlet</url-pattern> </servlet-mapping> </web-app>
1回答
同学你好!
这是浏览器对h2标签解析造成的,如果没有h1标签,浏览器不能够正常的解析h2标签。建议同学将代码中的h2标签改为h1

如果我的回答解决了你的疑惑,请采纳,祝学习愉快~
相似问题
回答 2
回答 2