SyntaxHighlighter 去官网下载下来导进来就可以了 注意jquery 不要重复
<%@ include file="/comm/ImportHead.jsp" %>
<%@ page isELIgnored="false" %>
<%@ page contentType="text/html;charset=UTF-8"%>
<html>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
<style>
</style>
</style>
<script type="text/javascript" src="<%=request.getContextPath()%>/plugins/da/dap/common/highlighter/scripts/shCore.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/plugins/da/dap/common/highlighter/scripts/shBrushSql.js"></script>
<script language="javascript" type="text/javascript" src="<%=request.getContextPath()%>/plugins/da/dap/js/jquery-1.4.2.min.js"></script>
<link type="text/css" rel="stylesheet" href="<%=request.getContextPath()%>/plugins/da/dap/common/highlighter/styles/shCore.css"/>
<link type="text/css" rel="stylesheet" href="<%=request.getContextPath()%>/plugins/da/dap/common/highlighter/styles/shThemeDefault.css"/>
</head>
<body scroll="no" οnlοad="closePWaitingTip()">
<pre id="code" name="code" class="brush:sql;"><bean:write name="DAProcModelMapForm" property="da_sql"/></pre><!--注意这块brush:js显示的是js的源码高亮-->
</body>
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = '<%=request.getContextPath()%>/plugins/da/dap/common/heighlighter/scripts/clipboard.swf';
SyntaxHighlighter.all();
//parent.sql=$('#code').html();
parent.sql="<bean:write name="DAProcModelMapForm" property="da_sql" filter="false"/>";
</script>
</html>
这么搞的话代码全是显示在一行。可以这样处理下。
<%
String sql=request.getAttribute("sql")==null?"":request.getAttribute("sql").toString();
int rowSize =100;//每行显示100个 自定义
int rowNum = sql.length()/rowSize+(sql.length()%rowSize>0?1:0);
String sqlStr[] = new String[rowNum];
if(!sql.equals("")){
for(int i=0;i<rowNum;i++){
if(i!=rowNum-1){
sqlStr[i]=sql.substring(i*rowSize,(i+1)*rowSize);
}else{
sqlStr[i]=sql.substring(i*rowSize);
}
}
}
%>
在显示代码中这样写 就哦了
<pre id="code" name="code" class="brush:sql;">
<%for(int i=0;i<rowNum;i++){%><%=sqlStr[i]%>
<%}%>
</pre>