JSP中WEB项目常用开头

来源:互联网 发布:云计算 安全问题 编辑:程序博客网 时间:2024/05/18 05:12
<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%><%    String path = request.getContextPath();    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fun"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <base href="<%=basePath%>"><title>Insert title here</title></head>

因为引入了<base href="<%=basePath%>">
故在路径中可以这样写

<form action="<%=basePath%>view/user/login.jsp" method="post">
0 0