*****************************************
lynx286原创, 首发
www.mydwbi.com
http://www.mydwbi.com/posts/list/44.page
欢迎转贴, 但转贴请不要删除此段版权说明.
*****************************************
如添加本网站联系我们,广告投放等两个页面.
1. 在modulesMapping.properties文件中添加:mydwbi=com.mydwbi.MydwbiAction
此文件用来映射模块名.即添加一个叫mydwbi的模块.
2. 在templatesMapping.properties文件中添加:
mydwbi.contact = contact.htm
mydwbi.advertisement = advertisement.htm
此文件映射action和result 模板的关系,学过freemarker的可能会好理解些.
3. 在urlPattern.properties中添加:
mydwbi.contact.0 =
mydwbi.advertisement.0 =
此文件设置每个action参数.我们这个action无参数.
4. 修改net.jforum.util.preferences.TemplateKeys类,添加:
public static final String MYDWBI_CONTACT = "mydwbi.contact";
public static final String MYDWBI_AD = "mydwbi.advertisement";
5. 新建一个类:com.mydwbi.MydwbiAction
package com.mydwbi;
import net.jforum.Command;
import net.jforum.util.preferences.TemplateKeys;
public class MydwbiAction extends Command {
public void list() {
}
public void contact() {
this.setTemplateName(TemplateKeys.MYDWBI_CONTACT);
}
public void advertisement() {
this.setTemplateName(TemplateKeys.MYDWBI_AD);
}
}
package com.mydwbi;
import net.jforum.Command;
import net.jforum.util.preferences.TemplateKeys;
public class MydwbiAction extends Command {
public void list() {
}
public void contact() {
this.setTemplateName(TemplateKeys.MYDWBI_CONTACT);
}
public void advertisement() {
this.setTemplateName(TemplateKeys.MYDWBI_AD);
}
}
6. 修改jforum\templates\default\header.htm, 添加:
view plaincopy to clipboardprint?
<a /mydwbi/contact")}"> <img />${I18n.getMessage("mydwbi.contact")} </a> </span>
<a /mydwbi/advertisement")}"> <img />${I18n.getMessage("mydwbi.Advertisement")} </a> </span>
<a /mydwbi/contact")}"> <img />${I18n.getMessage("mydwbi.contact")} </a> </span>
<a /mydwbi/advertisement")}"> <img />${I18n.getMessage("mydwbi.Advertisement")} </a> </span>
7. 添加两个文件contact.htm,advertisement.htm 在目录:jforum\templates\default\下:
contact.htm:
view plaincopy to clipboardprint?
<#include "header.htm"/>
<center>
${I18n.getMessage("mydwbi.contactDesc")}:
[email protected]
</center>
<#include "bottom.htm"/>
<#include "header.htm"/>
<center>
${I18n.getMessage("mydwbi.contactDesc")}:
[email protected]
</center>
<#include "bottom.htm"/>
advertisement.htm
view plaincopy to clipboardprint?
<#include "header.htm"/>
<center>
${I18n.getMessage("mydwbi.adDesc")}:
[email protected]
</center>
<#include "bottom.htm"/>
<#include "header.htm"/>
<center>
${I18n.getMessage("mydwbi.adDesc")}:
[email protected]
</center>
<#include "bottom.htm"/>
8. 添加国际化文件:
native2ascii -encoding GBK messages.properties messages_ZH.properties
注意要加-encoding 参数,且参数值不是utf8.