Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » Servlet/JSP/JSF/JavaFX Script
打印话题 寄给朋友 订阅主题 |
作者 | Re:求助:struts显示乱码问题 [Re:forget_ai] |
forget_ai
发贴: 10 |
于 2006-03-29 09:14
这是里面生成页面的程序 对了上面的程序要把eclipse去掉就可以直接导入了 //Created by MyEclipse Struts // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.0.1/xslt/JavaClass.xsl package com.romance.struts.action; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.Calendar; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import com.romance.struts.form.LogonForm; /** * MyEclipse Struts Creation date: 03-22-2006 * * XDoclet definition: * * @struts.action path="/logon" name="logonForm" input="/index.jsp" * scope="request" validate="true" */ public class LogonAction extends Action { // --------------------------------------------------------- Instance // Variables // --------------------------------------------------------- Methods /** * Method execute * * @param mapping * @param form * @param request * @param response * @return ActionForward */ private String path = new File("").getAbsolutePath(); private String filePath = path + "\\template.html";// 源模板文件 private String filename = String.valueOf(Calendar.getInstance() .getTimeInMillis()) + ".html";// 根据时间取得文件名 private String fileurl = path + "\\" + filename;// 生成的html文件保存路径 private String templateContent; public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException { ActionMessages errors = new ActionMessages(); LogonForm logonForm = (LogonForm) form; String titlehtm = logonForm.getTitle(); String editerhtm = logonForm.getEditer(); String contexthtm = logonForm.getContext(); if (!titlehtm.equals("") && !editerhtm.equals("") && !contexthtm.equals("")) { // 读取模块文件 FileInputStream fileinputstream = new FileInputStream(filePath); byte[] bytes = new byte[fileinputstream.available()]; fileinputstream.read(bytes); fileinputstream.close(); templateContent = new String(bytes); templateContent = templateContent.replaceAll("###title###", titlehtm); // 替换掉模块中相应的地方 templateContent = templateContent.replaceAll("###editer###", editerhtm); templateContent = templateContent.replaceAll("###context###", contexthtm); templateContent = templateContent.replaceAll("###filename###", filename); // 建立文件输出流 FileOutputStream fileoutputstream = new FileOutputStream(fileurl); byte tag_bytes[] = templateContent.getBytes(); fileoutputstream.write(tag_bytes); fileoutputstream.close(); return mapping.findForward("successed"); } else { errors.add("请补全内容", new ActionMessage("error.msg")); saveErrors(request, errors); return (new ActionForward(mapping.getInput())); } } } Java开发规范 |
话题树型展开 |
人气 | 标题 | 作者 | 字数 | 发贴时间 |
2387 | 求助:struts显示乱码问题 | forget_ai | 300 | 2006-03-29 09:10 |
1973 | Re:求助:struts显示乱码问题 | forget_ai | 3215 | 2006-03-29 09:14 |
1711 | Re:求助:struts显示乱码问题 | hoden_w | 869 | 2006-03-30 17:55 |
1710 | Re:求助:struts显示乱码问题 | andilyliao | 28 | 2006-04-04 08:58 |
已读帖子 新的帖子 被删除的帖子 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |