易截截图软件、单文件、免安装、纯绿色、仅160KB

JSP中输出CSV文件

<%@page import="com.opensymphony.xwork2.util.ValueStack"%><%
    ValueStack vs = (ValueStack)request.getAttribute("struts.valueStack");  
    String aa = (String)vs.findValue("downloadContent");
    response.setContentType("application/csv");
    response.setHeader("Content-Disposition", "inline; filename=result.csv");
    out.print(aa);
%>


相关文档:

jsp写的验证码

第一步:建立一个code.jsp的页面,产生随机码
   <%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK"
     import="java.io.*,
          java.util.*,
       & ......

jsp标准动作

//下面,从请求中得到属性 为一个 类,,会判断是否为null,,如为null则实例化
// id 值  相当于  class 的 对象名
<jsp:useBean id="order" class="com.entity.Order" scope="request" />
<==>
<%
 Order order=(Order)request.getAttribute("order");
 if(order==null)
  ......

JSP URL中文传参

 将参数写成 java.net.URLEncoder.encode(sContent,"gb2312")后再传递。
比如url是"/accept.do?content=<%=java.net.URLEncoder.encode(sContent,"UTF-8")%>";
读取时,使用
String sc =  new String(request.getParameter("content").getBytes("iso-8859-1"),"UTF-8"); ......

Jsp apache common fileupload 文件上传 乱码

在action里使用fileupload时,从reqeust得到的中文数据为乱码,尝试使用了
Java代码
1.   DiskFileItemFactory factory = new DiskFileItemFactory();  
    ServletFileUpload upload = new ServletFileUpload(factory);  
    upload.setHeaderEnco ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号