JSP

 

 

${ pageContext.request.contextPath}   =  프로젝트 명 가져오기

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
  <c:set var="home" value="${pageContext.request.contextPath}" />
 
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="home" content="${home}"  >

 

meta 태그로 위와 같이 작성후 

자바스크립트로 다음과 같이 사용

$home = $("meta[name='home']").attr("content");

 

 

 

도메인 주소와 프로젝트 Path 까지 포함해서 가져온다.

 

	public static String getDomain(HttpServletRequest req) {
        StringBuffer sbDomain = new StringBuffer(); 
        sbDomain.append(req.getScheme()).append("://").append(
        		req.getServerName()).append(":").append(
        				req.getServerPort()).append(req.getContextPath());
        return sbDomain.toString(); 
    }
	

 

 

about author

PHRASE

Level 1  라이트

댓글 ( 5)

댓글 남기기

작성