Laughing girl2021
2021-07-22 15:22
采纳率: 100%
浏览 32
已采纳

javaweb练习网页自动刷新,为什么无法显示页面数据


package com.pojo.test1;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "RefreshServlet", urlPatterns = "/refresh")
public class RefreshServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //自动跳转方法
        String message="<meta http-equiv=’refresh’ content=’3;url=Home.html’>3秒后自动跳转到首页,如果没有跳转,请点击<a href='Home.html'>跳转链接</a>";
        request.setAttribute("message",message);
        request.getRequestDispatcher("/index.jsp").forward(request,response);
    }

<%--
  Created by IntelliJ IDEA.
  User: pan
  Date: 2021/7/19
  Time: 10:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>$Title$</title>
  </head>
  <body>
<%=request.getAttribute("massage")%>
  </body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h2>来到我的网站!············</h2>
</body>
</html>

1条回答 默认 最新

相关推荐 更多相似问题