我收到了错误,请你帮忙
的servlet
public class FirstClass extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doGet(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
PrintWriter out = response.getWriter();
out.println("this is a sample");
out.flush();
}
public void doPost(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
PrintWriter out = response.getWriter();
out.println("this is a sample");
out.flush();
}
}
Run Code Online (Sandbox Code Playgroud)
web.xml中
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>hii</display-name>
<servlet>
<servlet-name>First</servlet-name>
<servlet-class>test.FirstClass</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>First</servlet-name>
<url-pattern>/first.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app> …Run Code Online (Sandbox Code Playgroud) 我想在过滤器内的HTML响应中用它们各自的HTML实体替换某些字符.字符包括<,>,&.我无法使用replaceAll(),因为它将替换所有字符,甚至是HTML标记的一部分.
这样做的最佳方法是什么?