JSP里用到的知识

1、编码格式设定:

<%@ contentType=”text/html;charset=UTF-8” language=”java” %>

2、重定向跳转网页:

<% response.senRedirect(“user/login”); %>

3、路径获取:

<% 以下代码 %>
    
String path = request.getContextPath(); 
//path:/WebDemo
    
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; //basePath:http:
//localhost:8683/WebDemo/  

String remoteAddress=request.getRemoteAddr(); 
//remoteAddr:127.0.0.1

String servletPath=request.getServletPath(); 
//servletPath:/index.jsp  

String realPath=request.getRealPath("/");  
//realPath:D:\apache-tomcat-6.0.13\webapps\WebDemo\

String requestURI=request.getRequestURI();
//requestURI:/WebDemo/index.jsp  

 

你可能感兴趣的:(前端相关)