[英]how to call a html page from spring boot application
I have tried using servlet , but it is not working. 我尝试使用servlet,但是它不起作用。 web.xml : web.xml:
<display-name>Password</display-name>
<servlet>
<servlet-name>SetPassword</servlet-name>
<servlet-class>com.cx.view.SetPassword</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SetPassword</servlet-name>
<url-pattern>/view/setPassword</url-pattern>
</servlet-mapping>
I have a HTML page in [email_templates/setPassword.html] 我在[email_templates / setPassword.html]中有一个HTML页面
java code : Java代码:
public class SetPassword extends HttpServlet {
private static final long serialVersionUID = 7514856921920494774L;
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
RequestDispatcher requestDispatcher = request
.getRequestDispatcher("email_templates/setPassword.html");
requestDispatcher.forward(request, response);
}
//tried for both get and post request //尝试获取和发布请求
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
RequestDispatcher requestDispatcher = request
.getRequestDispatcher("email_templates/setPassword.html");
requestDispatcher.forward(request, response);
}
} }
Url trying to access: http://localhost:8080/view/setPassword 尝试访问的网址: http:// localhost:8080 / view / setPassword
Spring boot serves automatically static resources from one of these directories: Spring Boot 自动从以下目录之一提供静态资源:
So try to save your page in one of these folders (I would suggest /static/ or /public/) 因此,尝试将页面保存在这些文件夹之一中(我建议使用/ static /或/ public /)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.