处理从页面传过来的字符集及获取项目路径

来源:互联网 发布:网络数据包分析软件 编辑:程序博客网 时间:2024/05/17 23:34

1.获取页面中的属性值:

String username = request.getParameter("username");

2.修改字符集格式

username = new String(username.getByte("ISO-8859-1"),"GB2312");

上面的getByte中的参数是页面中的字符集,String方法的第二个参数是目标字符集。

3.jsp页面获取路径两种方法

<c:out value="${pageContext.request.contextPath}"/>

<%=request.getContextPath()%>


原创粉丝点击