社长让做一个自己的博客,呵呵,相当大的工程啊,第一天把写博客的简单jsp页面做成了。
代码如下:
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<script type="text/javascript">
window.onload = function()
{
var oFCKeditor = new FCKeditor( 'content' ) ;
oFCKeditor.BasePath = "/blog/fckeditor/" ;
oFCKeditor.toolbarSet = "Default";
oFCKeditor.Height = 350;
oFCKeditor.ReplaceTextarea() ;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>my blog</title>
<style type="text/css">
<!--
.STYLE1 {
font-size: x-large;
font-weight: bold;
}
.STYLE2 {
font-size: 18px;
font-weight: bold;
}
.STYLE3 {
font-size: 16px;
font-weight: bold;
}
.STYLE4 {font-size: 14px}
.STYLE6 {font-size: 14px; font-weight: bold; }
-->
</style>
</head>
<body>
<p class="STYLE1">请输入您的博文内容</p>
<form id="form1" name="form1" method="post" action="/blog/BlogServlet_1">
<table width="812" height="415" border="0">
<tr>
<td width="54"><span class="STYLE2"><span class="STYLE4">主题</span>:</span></td>
<td width="748"><label>
<input name="title" type="text" size="60" />
</label></td>
</tr>
<tr>
<td><span class="STYLE3">类别:</span></td>
<td><label>
<select name="category">
<option value="1">心情故事</option>
<option value="2">旅游故事</option>
</select>
</label></td>
</tr>
<tr>
<td height="174"><span class="STYLE6">内容:</span> </td>
<td><label>
<textarea name="content" cols="100" rows="10" id="content"></textarea>
</label></td>
</tr>
<tr>
<td><label></label>
<input type="submit" name="Submit2" value="重置" /></td>
<td><label>
<input type="submit" name="Submit" value="提交" />
</label></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="120"> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
做的时候先用dreamweaver拉的框架之后然用EditPlus保存成jsp的页面。里面需要一点fckeditor。
如图:
做的时候出现点问题,总结一下:
先在fckeditor文件夹下找说明文档,根据提示将下面代码复制到</head>标签中。
window.onload = function()
{
var oFCKeditor = new FCKeditor( 'content') ) ;//根据自己的textarea name自定
oFCKeditor.BasePath = "/blog/fckeditor/"; //fckeditor前的路径自定
oFCKeditor.toolbarSet = "Default";
oFCKeditor.Height = 350;
oFCKeditor.ReplaceTextarea() ;
}
</script>
默认情况下,FCKEditor在进行文本编辑时,无法使用中文字体。解决方法如下:
打开 fckconfig.js 文件
FCKConfig.FontNames = 'Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;
将其修改为:
FCKConfig.FontNames = '宋体;黑体;幼圆;楷体_GB2312;仿宋_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;