小编use*_*652的帖子

此URL不支持HTTP方法GET

我收到了错误,请你帮忙

的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)

servlets

6
推荐指数
1
解决办法
2万
查看次数

用java中的HTML实体替换字符

我想在过滤器内的HTML响应中用它们各自的HTML实体替换某些字符.字符包括<,>,&.我无法使用replaceAll(),因为它将替换所有字符,甚至是HTML标记的一部分.

这样做的最佳方法是什么?

html escaping html-entities java-ee

4
推荐指数
2
解决办法
2万
查看次数

标签 统计

escaping ×1

html ×1

html-entities ×1

java-ee ×1

servlets ×1