最近遇到的问题整理,同时也想找个师傅~~~~~~~~~~ 期待~~
1.include 乱码问题
A.jsp
<jsp:include page="1.html"></jsp:inclue> 显示正常
<%@include page="1.html"%> 中文乱码
1.html
中国中国
2.乱码问题
A.jsp
File file=new File(getServletContext.getRealPath("123.html"));
File dir=new File(file.getParent());
if(!dir.exists()){
dir.mkdirs();
}
if(!file.exists()){
file.createNewFile();
}
FileWriter fw = new FileWriter(file);
fw.write("中国中国");
fw.close();
如果A.jsp在 项目Test里,那么 如果将Test直接部署到Tomcat的webapp 里,创建的123.html不会出现中文乱码,但是如果通过虚拟目录(即server.xml <context></context>)来部署项目的话,就会出现中
文乱码问题.
3.动态包含问题
现在的项目需求是:列表页面(如土特产页面)用的是shtml格式,点击查询时,用jsp页面,可jsp 和shtml 的包含其他页面语句不一样. (shtml:<!--#include virtual=""-->,jsp:<%@ include file=""%>或<jsp:include page=""></jsp:include>)
问题是 现在的包含页面存在嵌套包含
比如包含1.html 1.html 还会包含2.html 2.html 还会包含3.html的内容..
那么 1.html 2.html 里面都会有包含语句
如果是shtml格式,则<!--#include virtual=""-->
jsp:目前只能用<%@ include file=""%>
因为<jsp:include page=""></jsp:inclue>在html页面被包含进来后,不会对包含进来的语句进行编译..