public String TiKuWord() throws Exception{
System.out.println("aa"+aa);
listzujuan=ses.FindzuJuan(aa);
//listzujuan=ses.FindLianxi(aa);
//System.out.println(listzujuan.get(0).getShtitle());
Configuration configuration = newConfiguration();
configuration.setDefaultEncoding("utf-8");
// 模板放在com.canyou.template包下面,通过classpath装载
configuration.setClassForTemplateLoading(Tb_sc_selectAction.class,
"/com/ecsystem/action");
String zuzhuangcjr=(String) ActionContext.getContext().getSession().get("user");
Template t =configuration.getTemplate("yyyy"+".ftl");// 设置要装载的模板
String path =ServletActionContext.getServletContext().getRealPath("/paper");
File file = new File(path);
if(!file.exists()) {
file.mkdirs();
}
long d=(new Date()).getTime();
path=path+"\\"+zuzhuangcjr+d+".doc";
File outFile = new File(path);
if (!outFile.exists()) {
outFile.createNewFile();
}
Writer out = new BufferedWriter(newOutputStreamWriter(
new FileOutputStream(outFile),"utf-8"));
Map map = new HashMap
map.put("rows", listzujuan);
if(listzujuan!=null &&listzujuan.size()>0){
map.put("titless",aa);
}
t.process(map, out);
ActionContext.getContext().getSession().put("daochu","导出成功");
ActionContext.getContext().put("daochu1","http://218.69.93.91:8090/ECSystem/paper/"+zuzhuangcjr+d+".doc");
ActionContext.getContext().put("daochu2","点击下载");
return SUCCESS;
}
/**
* 注意:在下载的时候必须使用流的形式将其输出,注意文件的路径获取,
*/
File file = newFile("/"+downloadDir.trim()+"/" + d);
InputStream is = newFileInputStream(file); //以流的形式输出文件信息
return is;
<script type="text/javascript"> function bao(s){ if(s=="选择题"){ document.getElementById("xzta").style.display=''; document.getElementById("xztb").style.display=''; document.getElementById("xztc").style.display=''; document.getElementById("xztd").style.display=''; var selectA = $.trim($("#selectA").val()); var selectB = $.trim($("#selectB").val()); var selectC = $.trim($("#selectC").val()); var selectD = $.trim($("#selectD").val()); if(selectA == "" || selectB == "" || selectC == ""||selectD==""){ alert("输入信息不能为空!!!!"); return false; }
}else{ document.getElementById("xzta").style.display='none'; document.getElementById("xztb").style.display='none'; document.getElementById("xztc").style.display='none'; document.getElementById("xztd").style.display='none'; } } script> ------------------------------------------------ $(document).ready(function() { $("#sub").bind( "click", function(event) { var cids=$("#cc1").combo("getValue"); var xmids=$("#dd").combo("getValue"); var ees=$("#ee").combo("getValue"); var selectname = $.trim($("#selectname").val()); //var selectgrade = $.trim($("#selectgrade").val()); var selectanswer = $.trim($("#selectanswer").val()); var selecttype = $.trim($("#selecttype").val()); //alert(8888); if (selectname == "" ||selectanswer==""||selecttype=="" ||cids=="" || xmids=="" ||ees=="") { alert("输入信息不能为空!!!!"); return false; } if ($.trim($("#selectname").val()) != "") { //查询username是否被占用 $.post("selectExist.action", { selectname : $("#selectname").val() }, function(data) { if (data ==1) { alert("试题题目已经存在"); return false; } if(bao($("#s").val())==false){ return false; }
else{ document.addselect.action="addSelect.action"; document.addselect.target="i_frame" document.addselect.submit(); } }); } }); <select name="selecttixing" id="s" onchange="bao(this.value)" > <option value="选择题">选择题option> <option value="判断题">判断题option> select> |
$(document).ready(function(){ $("#sub").click(function(){ if($('#cc1').combobox('getValue')==""){ alert("请选择课程"); } else{ //此处添加 id="xznum" id="xzscore" id="pdnum" id="pdscore" var xznum=parseInt($("#xznum").val()); var xzscore=parseInt($("#xzscore").val()); var pdnum=parseInt($("#pdnum").val()); var pdscore=parseInt($("#pdscore").val()); var z = xzscore%xznum; var v = pdscore%pdnum; if(xzscore + pdscore==100){ if(z == 0){ if(v==0){
if ($.trim($("#shtitle").val()) != "") { //查询username是否被占用 $.post("ShiJuanexist.action", { shtitle : $("#shtitle").val()
}, function(data) {
if (data ==0) { //alert("试卷名可以使用!!");
$("#thform").submit(); }else{ alert("试卷名不能使用!!"); }
}); } else{ alert("试题名不能为空!!");
}
// return true;
} else{ alert("判断总分不能整除题目个数,请重新输入!!!"); // return false; } } else{ alert("选择总分不能整除题目个数,请重新输入!!!"); // return false; }
} else{ alert("选择和判断分数之和不为100,请重新输入!!!"); // return false; }
}; });
});
|
style="background-color: white; width: 390px; position: absolute; top: 100px; left: 100px; border: 1px solid #ddd; -webkit-box-shadow: 0px 0px 8px #ccc; -moz-box-shadow: 0px 0px 8px #ccc; box-shadow: 0px 0px 8px #ccc; z-index: 10">
|