动态jsp转换成静态html
如题,我用jsp写的一个问卷调查的页面,里面嵌套了些复杂的样式、JS。现在有两个难点:
1、以邮件形式发送的话,邮件正文肯定得包含表单,比如radio表单,或者普通文本框之类的,这个怎么实现?或者需要注意什么
2、现在需要把这个页面通过邮件正文的形式发送出去,让客户作答,这就需要吧jsp转换成HTML。该如何转换呢?
--------------------编程问答-------------------- 不用转呀,写在jsp页面中就可以了 --------------------编程问答-------------------- HTML能办的事,JSP肯定能办得到 --------------------编程问答-------------------- jsp 编译后就是html --------------------编程问答-------------------- 查看原文件,应该就可以看到了,我们看到的就是html静态页面 --------------------编程问答-------------------- +1 正解. --------------------编程问答-------------------- 你能把html的转换成jsp的吗 ,反方系iangjiu 了 --------------------编程问答-------------------- jsp通过编译成为class文件,然后再翻译成html文件 --------------------编程问答-------------------- 远程提交表单吧 action改成对应IP端口以及工程路径
<form action="http://localhost:8080/test/servlet/test" method="post">
然后把整个以html格式当做邮件正文发过去就行了 --------------------编程问答-------------------- 你可以看下动态页面静态化方面的资料,记得是用的插件实现的 --------------------编程问答-------------------- --------------------编程问答-------------------- jsp 编译后不就是html吗。。。 --------------------编程问答-------------------- 还是直接发个链接过去吧 --------------------编程问答-------------------- 看了你们的回答,感觉都不大对劲呀。
jsp编译成html,这个过程到底是怎么样的?咋都没提呀?
查看源文件这个方法更是不可取的,需要通过程序实现的 --------------------编程问答--------------------
你查看源文件,然后把源文件保存,拿到其他机器上打开看看??不可取!!!
里面引用的js 全丢失了 --------------------编程问答--------------------
这个看起来整体思路是对的吧,但就不知道怎么通过程序实现 --------------------编程问答-------------------- jsp 部署后 第一次访问才编译成class文件
但最终这个文件还是个servlet --------------------编程问答--------------------
--------------------编程问答-------------------- 不用转,jsp 发布以后 显示的是html --------------------编程问答-------------------- 我想你的意思是动态页面静态化,有插件可以实现,在网上搜一下 --------------------编程问答--------------------
先建立一个模板页面:template.htm
<html><head><title>###title###</title>
<meta http- equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../css.css" rel=stylesheet type=text/css></head>
<body>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="2">
<tr><td align="center">###title###</tr>
<tr><td align="center">作者:###author###</tr>
<tr><td align="center">###content###</td></tr>
</table>
</body>
</html>
再写一个Java页面: buildhtml.java:
import java.util.*;
import java.io.*;
public class HtmlFile{
public static void main(String[] args){
try{
String title="Make Html";
String content="小样,还搞不定你?";
String editer="Hulihutu";
String filePath = "";
filePath ="template.html";
System.out.print(filePath);
String templateContent="";
FileInputStream fileinputstream = new FileInputStream(filePath);// 读取模板文件
int lenght = fileinputstream.available();
byte bytes[] = new byte[lenght];
fileinputstream.read(bytes);
fileinputstream.close();
templateContent = new String(bytes);
System.out.print(templateContent);
templateContent=templateContent.replaceAll("###title###",title);
templateContent=templateContent.replaceAll("###content###",content);
templateContent=templateContent.replaceAll("###author###",editer);// 替换掉模板中相应的地方
System.out.print(templateContent);
// 根据时间得文件名
Calendar calendar = Calendar.getInstance();
String fileame = String.valueOf(calendar.getTimeInMillis()) +".html";
fileame = "/" + fileame;// 生成的html文件保存路径。
FileOutputStream fileoutputstream = new FileOutputStream(fileame);// 建立文件输出流
System.out.print("文件输出路径:");
System.out.print(fileame);
byte tag_bytes[] = templateContent.getBytes();
fileoutputstream.write(tag_bytes);
fileoutputstream.close();
}catch(Exception e){
System.out.print(e.toString());
}
}
}
public class Test{
private String name;
private int age;
public void setName(String name){
this.name=name;
}
public String getName(){
return this.name;
}
public void setAge(int age){
this.age=age;
}
public int getAge(){
return this.age;
}
}
补充:Java , Web 开发