当前位置: 编程技术>移动开发
本页文章导读:
▪poi 导出Excel 2003 跟 2007 版本 poi 导出Excel 2003 和 2007 版本
package utils;import java.io.OutputStream;import org.apache.poi.hssf.usermodel.HSSFCell;import org.apache.poi.hssf.usermodel.HSSFCellStyle;import org.apache.poi.hssf.usermodel.HSSFDataFormat;import org.apache.p.........
▪ 銆愯浆銆慉ndroid涓浠楢NR鐨凬绉嶆鍣 銆愯浆銆慉ndroid涓浠楢NR鐨凬绉嶆鍣?
杞嚜锛歨ttp://hubingforever.blog.163.com/blog/static/17104057920126297441480/浠ュ墠鍋欰ndroid绯荤粺寮€鍙戯紝涓€鑸緢灏戝啓绋嬪簭銆傜幇鍦ㄥ埌涓€鍏.........
▪ Jquery ajva 页面请求 (留言板 交付) Jquery ajva 页面请求 (留言板 提交)
<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
.........
[1]poi 导出Excel 2003 跟 2007 版本
来源: 互联网 发布时间: 2014-02-18
poi 导出Excel 2003 和 2007 版本
package utils;
import java.io.OutputStream;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFDataFormat;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class PoiExportExcel {
public static void PoiWriteExcel_To2007(String title, String[][] head,String[][]body, OutputStream os){
XSSFWorkbook xssf_w_book=new XSSFWorkbook();
XSSFSheet xssf_w_sheet=xssf_w_book.createSheet(title);
XSSFRow xssf_w_row=null;//创建一行
XSSFCell xssf_w_cell=null;//创建每个单元格
int col_count = 0;
int row_count = 0;
row_count = body.length;
col_count = head.length;
XSSFCellStyle head_cell宋体");//设置头部字体为宋体
head_font.setBoldweight(Font.BOLDWEIGHT_BOLD); //粗体
head_font.setFontHeightInPoints((short) 12);
head_cellStyle.setFont(head_font);//单元格样式使用字体
int titleRows = 0; //标题占据的行数
xssf_w_row=xssf_w_sheet.createRow(0+titleRows);//第一行写入标题行
for(int i = 0; i < col_count; i++){
xssf_w_cell = xssf_w_row.createCell((short)i);
String type=head[i][2];
if(type==null){
type="";
}
else if(type.equals("DATE")){
System.out.println("走格式化日期这步了");
XSSFDataFormat head_format=xssf_w_book.createDataFormat();
head_cellStyle.setDataFormat(head_format.getFormat("m/d/yy"));
xssf_w_cell.setCellType(XSSFCell.CELL_TYPE_STRING);
XSSFRichTextString xssfString =new XSSFRichTextString(head[i][0]);
xssf_w_cell.setCellValue(xssfString);
xssf_w_cell.setCellStyle(head_cellStyle);
xssf_w_sheet.autoSizeColumn((short)i);
}else{
XSSFDataFormat head_format=xssf_w_book.createDataFormat();
head_cellStyle.setDataFormat(head_format.getFormat("@"));
xssf_w_cell.setCellType(XSSFCell.CELL_TYPE_STRING);
XSSFRichTextString xssfString =new XSSFRichTextString(head[i][0]);
xssf_w_cell.setCellValue(xssfString);
xssf_w_cell.setCellStyle(head_cellStyle);
xssf_w_sheet.autoSizeColumn((short)i);
}
}
XSSFCellStyle cellStyle_CN=xssf_w_book.createCellStyle();//创建数据单元格样式(数据库数据样式)
cellStyle_CN.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyle_CN.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyle_CN.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyle_CN.setBorderTop(XSSFCellStyle.BORDER_THIN);
for(int i = 1; i <= row_count; i++){
xssf_w_row = xssf_w_sheet.createRow(i+titleRows);
for(int j = 0; j < col_count; j++){
String val=head[j][1];
xssf_w_cell = xssf_w_row.createCell((short)j);
if(val==null || val.trim().equals(""))
val="0";
String type=head[j][2];
if(type==null)
type="";
//判断类型为数字类型
else if(type.equals("NUM")){
xssf_w_cell.setCellType(XSSFCell.CELL_TYPE_STRING);
String value=body[i-1][Integer.parseInt(val)];
if(value==null || value.trim().equals(""))
value="0";
xssf_w_cell.setCellValue(Double.parseDouble(value));
}
//判断类型为日期类型
else if(type.equals("DATE")){
xssf_w_cell.setCellType(XSSFCell.CELL_TYPE_STRING);//设置单元格为字符串类型
XSSFDataFormat format=xssf_w_book.createDataFormat();
cellStyle_CN.setDataFormat(format.getFormat("yyyy/MM/dd"));
String value=body[i-1][Integer.parseInt(val)];
XSSFRichTextString xssfString =new XSSFRichTextString(value);
xssf_w_cell.setCellStyle(cellStyle_CN);
xssf_w_cell.setCellValue(xssfString);
}else{
xssf_w_cell.setCellType(XSSFCell.CELL_TYPE_STRING);//设置单元格为字符串类型
String value=body[i-1][Integer.parseInt(val)];
if(value==null )
value="";
XSSFDataFormat format=xssf_w_book.createDataFormat();
cellStyle_CN.setDataFormat(format.getFormat("@"));
xssf_w_cell.setCellStyle(cellStyle_CN);
XSSFRichTextString xssfString =new XSSFRichTextString(value);
xssf_w_cell.setCellValue(xssfString);
}
}
}
try{
xssf_w_book.write(os);
os.flush();
os.close();
}
catch(Exception e){
e.printStackTrace();
}
}
public static void PoiWriteExcel_To2003(String title, String[][] head, String[][] body, OutputStream os){
HSSFWorkbook hssf_w_wk = new HSSFWorkbook();//创建excel
HSSFSheet hssf_w_s = hssf_w_wk.createSheet(title);//创建一个工作空间
HSSFRow hssf_w_r = null;//创建一行
HSSFCell hssf_w_c = null;//每个单元格
//填写内容
int col_count = 0;
int row_count = 0;
row_count = body.length;
col_count = head.length;
HSSFCellStyle cellStyle = hssf_w_wk.createCellStyle();
HSSFFont font = hssf_w_wk.createFont();
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 10);
font.setFontName("宋体");//设置标题字体
cellStyle.setFont(font);
//标题
int titleRows = 0; //标题占据的行数
hssf_w_r = hssf_w_s.createRow(0);
//第一行写入标题行
hssf_w_r = hssf_w_s.createRow(0+titleRows);
cellStyle = hssf_w_wk.createCellStyle();
cellStyle.setFont(font);//设置列标题样式
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
for(int i = 0; i < col_count; i++){
hssf_w_c = hssf_w_r.createCell((short)i);
String type=head[i][2];
System.out.println("类型为"+type);
if(type==null){
type="";
}
else if(type.equals("DATE")){
HSSFDataFormat format1= hssf_w_wk.createDataFormat();
cellStyle.setDataFormat(format1.getFormat("m/d/yy"));
hssf_w_c.setCellType(HSSFCell.CELL_TYPE_STRING);
HSSFRichTextString hssfString = new HSSFRichTextString(head[i][0]);
hssf_w_c.setCellValue(hssfString);
hssf_w_c.setCellStyle(cellStyle);
hssf_w_s.autoSizeColumn((short)i);
}else{
HSSFDataFormat format = hssf_w_wk.createDataFormat();
cellStyle.setDataFormat(format.getFormat("@"));
hssf_w_c.setCellType(HSSFCell.CELL_TYPE_STRING);
HSSFRichTextString hssfString = new HSSFRichTextString(head[i][0]);
hssf_w_c.setCellValue(hssfString);
hssf_w_c.setCellStyle(cellStyle);
hssf_w_s.autoSizeColumn((short)i);
}
}
//第二行开始写入数据
cellStyle = hssf_w_wk.createCellStyle();
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
for(int i = 1; i <= row_count; i++){
hssf_w_r = hssf_w_s.createRow(i+titleRows);
for(int j = 0; j < col_count; j++){
String val=head[j][1];
hssf_w_c = hssf_w_r.createCell((short)j);
if(val==null || val.trim().equals(""))
val="0";
String type=head[j][2];
if(type==null)
type="";
//判断类型为数字类型
else if(type.equals("NUM")){
hssf_w_c.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
String value=body[i-1][Integer.parseInt(val)];
if(value==null || value.trim().equals(""))
value="0";
hssf_w_c.setCellValue(Double.parseDouble(value));
}
//判断类型为日期类型
else if(type.equals("DATE")){
HSSFDataFormat format1= hssf_w_wk.createDataFormat();
cellStyle.setDataFormat(format1.getFormat("yyyy/m/d/"));
String value=body[i-1][Integer.parseInt(val)];
HSSFRichTextString hssfString = new HSSFRichTextString(value);
hssf_w_c.setCellStyle(cellStyle);
hssf_w_c.setCellValue(hssfString);
}else{
hssf_w_c.setCellType(HSSFCell.CELL_TYPE_STRING);
String value=body[i-1][Integer.parseInt(val)];
if(value==null )
value="";
HSSFDataFormat format2 = hssf_w_wk.createDataFormat();
cellStyle.setDataFormat(format2.getFormat("@"));
hssf_w_c.setCellStyle(cellStyle);
HSSFRichTextString hssfString = new HSSFRichTextString(value);
hssf_w_c.setCellValue(hssfString);
}
}
}
try{
hssf_w_wk.write(os);
os.flush();
os.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}
package utils;
import java.io.OutputStream;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFDataFormat;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class PoiExportExcel {
public static void PoiWriteExcel_To2007(String title, String[][] head,String[][]body, OutputStream os){
XSSFWorkbook xssf_w_book=new XSSFWorkbook();
XSSFSheet xssf_w_sheet=xssf_w_book.createSheet(title);
XSSFRow xssf_w_row=null;//创建一行
XSSFCell xssf_w_cell=null;//创建每个单元格
int col_count = 0;
int row_count = 0;
row_count = body.length;
col_count = head.length;
XSSFCellStyle head_cell宋体");//设置头部字体为宋体
head_font.setBoldweight(Font.BOLDWEIGHT_BOLD); //粗体
head_font.setFontHeightInPoints((short) 12);
head_cellStyle.setFont(head_font);//单元格样式使用字体
int titleRows = 0; //标题占据的行数
xssf_w_row=xssf_w_sheet.createRow(0+titleRows);//第一行写入标题行
for(int i = 0; i < col_count; i++){
xssf_w_cell = xssf_w_row.createCell((short)i);
String type=head[i][2];
if(type==null){
type="";
}
else if(type.equals("DATE")){
System.out.println("走格式化日期这步了");
XSSFDataFormat head_format=xssf_w_book.createDataFormat();
head_cellStyle.setDataFormat(head_format.getFormat("m/d/yy"));
xssf_w_cell.setCellType(XSSFCell.CELL_TYPE_STRING);
XSSFRichTextString xssfString =new XSSFRichTextString(head[i][0]);
xssf_w_cell.setCellValue(xssfString);
xssf_w_cell.setCellStyle(head_cellStyle);
xssf_w_sheet.autoSizeColumn((short)i);
}else{
XSSFDataFormat head_format=xssf_w_book.createDataFormat();
head_cellStyle.setDataFormat(head_format.getFormat("@"));
xssf_w_cell.setCellType(XSSFCell.CELL_TYPE_STRING);
XSSFRichTextString xssfString =new XSSFRichTextString(head[i][0]);
xssf_w_cell.setCellValue(xssfString);
xssf_w_cell.setCellStyle(head_cellStyle);
xssf_w_sheet.autoSizeColumn((short)i);
}
}
XSSFCellStyle cellStyle_CN=xssf_w_book.createCellStyle();//创建数据单元格样式(数据库数据样式)
cellStyle_CN.setBorderBottom(XSSFCellStyle.BORDER_THIN);
cellStyle_CN.setBorderLeft(XSSFCellStyle.BORDER_THIN);
cellStyle_CN.setBorderRight(XSSFCellStyle.BORDER_THIN);
cellStyle_CN.setBorderTop(XSSFCellStyle.BORDER_THIN);
for(int i = 1; i <= row_count; i++){
xssf_w_row = xssf_w_sheet.createRow(i+titleRows);
for(int j = 0; j < col_count; j++){
String val=head[j][1];
xssf_w_cell = xssf_w_row.createCell((short)j);
if(val==null || val.trim().equals(""))
val="0";
String type=head[j][2];
if(type==null)
type="";
//判断类型为数字类型
else if(type.equals("NUM")){
xssf_w_cell.setCellType(XSSFCell.CELL_TYPE_STRING);
String value=body[i-1][Integer.parseInt(val)];
if(value==null || value.trim().equals(""))
value="0";
xssf_w_cell.setCellValue(Double.parseDouble(value));
}
//判断类型为日期类型
else if(type.equals("DATE")){
xssf_w_cell.setCellType(XSSFCell.CELL_TYPE_STRING);//设置单元格为字符串类型
XSSFDataFormat format=xssf_w_book.createDataFormat();
cellStyle_CN.setDataFormat(format.getFormat("yyyy/MM/dd"));
String value=body[i-1][Integer.parseInt(val)];
XSSFRichTextString xssfString =new XSSFRichTextString(value);
xssf_w_cell.setCellStyle(cellStyle_CN);
xssf_w_cell.setCellValue(xssfString);
}else{
xssf_w_cell.setCellType(XSSFCell.CELL_TYPE_STRING);//设置单元格为字符串类型
String value=body[i-1][Integer.parseInt(val)];
if(value==null )
value="";
XSSFDataFormat format=xssf_w_book.createDataFormat();
cellStyle_CN.setDataFormat(format.getFormat("@"));
xssf_w_cell.setCellStyle(cellStyle_CN);
XSSFRichTextString xssfString =new XSSFRichTextString(value);
xssf_w_cell.setCellValue(xssfString);
}
}
}
try{
xssf_w_book.write(os);
os.flush();
os.close();
}
catch(Exception e){
e.printStackTrace();
}
}
public static void PoiWriteExcel_To2003(String title, String[][] head, String[][] body, OutputStream os){
HSSFWorkbook hssf_w_wk = new HSSFWorkbook();//创建excel
HSSFSheet hssf_w_s = hssf_w_wk.createSheet(title);//创建一个工作空间
HSSFRow hssf_w_r = null;//创建一行
HSSFCell hssf_w_c = null;//每个单元格
//填写内容
int col_count = 0;
int row_count = 0;
row_count = body.length;
col_count = head.length;
HSSFCellStyle cellStyle = hssf_w_wk.createCellStyle();
HSSFFont font = hssf_w_wk.createFont();
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 10);
font.setFontName("宋体");//设置标题字体
cellStyle.setFont(font);
//标题
int titleRows = 0; //标题占据的行数
hssf_w_r = hssf_w_s.createRow(0);
//第一行写入标题行
hssf_w_r = hssf_w_s.createRow(0+titleRows);
cellStyle = hssf_w_wk.createCellStyle();
cellStyle.setFont(font);//设置列标题样式
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
for(int i = 0; i < col_count; i++){
hssf_w_c = hssf_w_r.createCell((short)i);
String type=head[i][2];
System.out.println("类型为"+type);
if(type==null){
type="";
}
else if(type.equals("DATE")){
HSSFDataFormat format1= hssf_w_wk.createDataFormat();
cellStyle.setDataFormat(format1.getFormat("m/d/yy"));
hssf_w_c.setCellType(HSSFCell.CELL_TYPE_STRING);
HSSFRichTextString hssfString = new HSSFRichTextString(head[i][0]);
hssf_w_c.setCellValue(hssfString);
hssf_w_c.setCellStyle(cellStyle);
hssf_w_s.autoSizeColumn((short)i);
}else{
HSSFDataFormat format = hssf_w_wk.createDataFormat();
cellStyle.setDataFormat(format.getFormat("@"));
hssf_w_c.setCellType(HSSFCell.CELL_TYPE_STRING);
HSSFRichTextString hssfString = new HSSFRichTextString(head[i][0]);
hssf_w_c.setCellValue(hssfString);
hssf_w_c.setCellStyle(cellStyle);
hssf_w_s.autoSizeColumn((short)i);
}
}
//第二行开始写入数据
cellStyle = hssf_w_wk.createCellStyle();
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
for(int i = 1; i <= row_count; i++){
hssf_w_r = hssf_w_s.createRow(i+titleRows);
for(int j = 0; j < col_count; j++){
String val=head[j][1];
hssf_w_c = hssf_w_r.createCell((short)j);
if(val==null || val.trim().equals(""))
val="0";
String type=head[j][2];
if(type==null)
type="";
//判断类型为数字类型
else if(type.equals("NUM")){
hssf_w_c.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
String value=body[i-1][Integer.parseInt(val)];
if(value==null || value.trim().equals(""))
value="0";
hssf_w_c.setCellValue(Double.parseDouble(value));
}
//判断类型为日期类型
else if(type.equals("DATE")){
HSSFDataFormat format1= hssf_w_wk.createDataFormat();
cellStyle.setDataFormat(format1.getFormat("yyyy/m/d/"));
String value=body[i-1][Integer.parseInt(val)];
HSSFRichTextString hssfString = new HSSFRichTextString(value);
hssf_w_c.setCellStyle(cellStyle);
hssf_w_c.setCellValue(hssfString);
}else{
hssf_w_c.setCellType(HSSFCell.CELL_TYPE_STRING);
String value=body[i-1][Integer.parseInt(val)];
if(value==null )
value="";
HSSFDataFormat format2 = hssf_w_wk.createDataFormat();
cellStyle.setDataFormat(format2.getFormat("@"));
hssf_w_c.setCellStyle(cellStyle);
HSSFRichTextString hssfString = new HSSFRichTextString(value);
hssf_w_c.setCellValue(hssfString);
}
}
}
try{
hssf_w_wk.write(os);
os.flush();
os.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}
[2] 銆愯浆銆慉ndroid涓浠楢NR鐨凬绉嶆鍣
来源: 互联网 发布时间: 2014-02-18
銆愯浆銆慉ndroid涓浠楢NR鐨凬绉嶆鍣?
杞嚜锛歨ttp://hubingforever.blog.163.com/blog/static/17104057920126297441480/
浠ュ墠鍋欰ndroid绯荤粺寮€鍙戯紝涓€鑸緢灏戝啓绋嬪簭銆傜幇鍦ㄥ埌涓€鍏徃鍋欰ndroid浜掕仈缃戝簲鐢紝绋嬪簭涓笉鏃跺嚭鐜颁竴浜汚NR銆?
涓婂嘲瀵笰NR闈炲父鐨勫叧娉紝鏈熸湜鎴戣兘褰诲簳瑙e喅璇ラ」鐩殑ANR銆傗姍锕忊姍b姹楋紒
鍥犳鎴戝ANR杩涜浜嗕簺鎬濊€冿紝骞跺拰鍒氫粠鑵捐QQ椤圭洰缁勮烦妲芥潵鍏徃鍖椾含鎬婚儴鐨勬煇鏋舵瀯甯堝悓浜嬭繘琛屼簡鎺㈣銆備粬涔熷熀鏈鍚屾垜鐨勮鐐广€?
鐜板皢鎴戝簲瀵笰NR鐨勬€濊矾鏁寸悊濡備笅锛?
涓€銆佸湪椤圭洰涔嬪墠锛屽簲璇ョ‘淇濆伐绋嬪笀鐞嗚В浜х敓ANR鐨勫熀鏈師鐞嗭紝Handler鐨勫熀鏈師鐞嗭紝鏄庣櫧涓€浜涗富瑕佸洖璋冨嚱鏁扮殑鎵ц绾跨▼銆傚鏋滃伐绋嬪笀杩樻病杈惧埌杩欎簺瑕佹眰锛屽簲璇ラ€氳繃鍩硅绛夋柟寮忓敖閲忚宸ョ▼甯堜簡瑙h繖浜涚煡璇嗐€?
鍏充簬杩欎簺鎶€鏈殑鐭ヨ瘑鍙弬鑰冦€婂叧浜嶢NR鐨勫畼鏂瑰缓璁€嬪拰銆夾ndroid绾跨▼妯″瀷銆嬪拰銆奓ooper鍜孒andler銆?
浜屻€佸鏋滅▼搴忓湪鍒濆鍖栭樁娈佃緝鑰楁椂锛岃€冭檻鏄剧ず涓€splash灞忔垨鑰呭敖蹇涓昏鍥惧揩閫熸樉绀哄鐞嗭紝鐒跺悗鎵嶆樉绀哄叾浠栫殑瑙嗗浘銆備笉绠℃槸鍝竴绉嶆儏鍐碉紝搴旇璁炬硶琛ㄦ槑绋嬪簭姝e湪寰€鍓嶆墽琛岋紝浠ュ厤鐢ㄦ埛瑙夊緱搴旂敤鍐荤粨浜嗐€?
涓夈€佸湪杩涜鏋舵瀯璁捐鏃讹紝鏋舵瀯甯堝簲璇ュ敖閲忛噰鐢∕VC鏋舵瀯锛屽彟澶栦竴瀹氳娓呮閭d簺浠g爜搴旇鏄湪涓荤嚎绋嬩腑鎵ц锛岄偅浜涗唬鐮佸簲璇ユ槸鍦ㄩ潪涓荤嚎绋嬩腑鎵ц銆傚綋鐒惰鍋氬ソ妗嗘灦涔熶笉瀹规槗鍟婏紒鈯欙箯鈯檅姹楋紒
鍥涖€佸浜庡凡澶勪簬椤圭洰涓悗鏈燂紝鑰屾病鏈夐噰鐢∕VC妗嗘灦锛屾垨鑰呴噰鐢ㄤ簡MVC妗嗘灦浣嗗叾瀹炵幇骞朵笉澶ソ鐨勯」鐩紝搴旇鐢诲嚭鍏舵暣浣撴鏋跺浘锛屾椂搴忓浘绛夎繘琛屽垎鏋愶紝灏介噺閲囩敤杈冨皬鐨勪唬浠凤紝閫愭杩唬鐨勬柟寮忚鍏堕」鐩渶鍚庤揪鍒拌壇濂界殑MVC鏋舵瀯銆傚浜庢垜浠殑褰撳墠椤圭洰锛屾垜姝h瘯鍥句娇鐢ㄨ鏂瑰紡鏉ユ渶澶х▼搴︾殑閬垮厤ANR銆備篃涓嶇煡閬撴渶鍚庤兘涓嶈兘杈惧埌寰堝ソ鐨勬晥鏋溿€?
浜斻€佸湪杩涜缂栫爜鏃讹紝宸ョ▼甯堜竴瀹氳鑰冭檻褰撳墠浠g爜姝诲惁鍦ㄤ富绾跨▼涓墽琛岋紱褰撳墠浠g爜鏄惁鏄€楁椂鎿嶄綔;
绾跨▼瀵归攣鐨勭珵浜夋槸鍚﹀彲鑳介€犳垚浠g爜鐨勭瓑寰咃紝鑰岃€楁椂澶锛涗唬鐮佹槸鍚﹀彲鑳介€犳垚姝婚攣锛岃€屼骇鐢烝NR銆?
鍏€佸鏋滃簲鐢ㄧ▼搴忎腑浣跨敤浜嗙涓夋柟鐨勫簲鐢ㄧ▼搴忥紝璇锋妸杩欎簺绗笁鏂圭殑搴旂敤绋嬪簭鍋氫负鍗曠嫭鐨勮繘绋嬫潵澶勭悊锛屼互閬垮厤瀹冪殑涓嶈壇浠g爜鑰岄€犳垚鏈」鐩嚭鐜癆NR銆傚叧浜庢鎶€鏈鍙傝€冦€夾ndroid涓崟APK搴旂敤澶氳繘绋嬨€?
涓冦€佸湪绋嬪簭杩愯鏃讹紝鍑虹幇浜咥NR锛屽伐绋嬪笀搴旇閫氳繃/data/anr/traces.txt骞剁粨鍚堜唬鐮侊紝杩涜ANR鐨勫垎鏋愩€?
鍏€佸湪椤圭洰涓悗鏈燂紝浣犲彲浠ヤ娇鐢?StrictMode 鏉ュ府鍔╀綘鍦ㄤ富绾跨▼涓煡鎵炬綔鍦ㄧ殑鑰楁椂鎿嶄綔锛屾瘮濡傚缃戠粶鎴栨暟鎹簱鎿嶄綔銆?
涔濄€佸湪椤圭洰鍚庢湡锛屽簲璇ラ€氳繃monkey绛夋潵杩涜鍘嬪姏娴嬭瘯锛屾壘鍑烘綔鍦ㄧ殑ANR锛屽苟杩涜淇敼銆?
鍏充簬monkey鐨勪娇鐢ㄨ鍙傝€冦€夾ndroid鐨刴onkey鐢ㄦ硶銆?
鍗併€佸浜庝竴浜涢噸瑕佺殑ANR鍙婁笉鑹唬鐮侊紝瑕佽繘琛屽綊绾冲拰鎬荤粨锛屽舰鎴愭枃妗o紝浠ヤ究鍒嗕韩缁欏叾浠栫殑鍚屼簨鎴栭」鐩粍锛屽苟浣滀负鏂板憳宸ョ殑鍩硅璧勬枡銆?
鎬荤粨
姣忓綋浜х敓ANR鎴戜滑鍙互鏍规嵁/data/anr/traces.txt鍒嗘瀽瑙e喅锛屼絾杩欎釜椤界柧寰堥毦浠庢牴鏈笂瑙e喅锛屽彧鏈夐€氳繃寮曞叆濂界殑妗嗘灦锛堟瘮濡侻VC妗嗘灦锛夛紝鎻愬崌寮€鍙戝伐绋嬪笀璁ょ煡锛屾妧鏈Н绱幓閬垮厤銆?
杞嚜锛歨ttp://hubingforever.blog.163.com/blog/static/17104057920126297441480/
浠ュ墠鍋欰ndroid绯荤粺寮€鍙戯紝涓€鑸緢灏戝啓绋嬪簭銆傜幇鍦ㄥ埌涓€鍏徃鍋欰ndroid浜掕仈缃戝簲鐢紝绋嬪簭涓笉鏃跺嚭鐜颁竴浜汚NR銆?
涓婂嘲瀵笰NR闈炲父鐨勫叧娉紝鏈熸湜鎴戣兘褰诲簳瑙e喅璇ラ」鐩殑ANR銆傗姍锕忊姍b姹楋紒
鍥犳鎴戝ANR杩涜浜嗕簺鎬濊€冿紝骞跺拰鍒氫粠鑵捐QQ椤圭洰缁勮烦妲芥潵鍏徃鍖椾含鎬婚儴鐨勬煇鏋舵瀯甯堝悓浜嬭繘琛屼簡鎺㈣銆備粬涔熷熀鏈鍚屾垜鐨勮鐐广€?
鐜板皢鎴戝簲瀵笰NR鐨勬€濊矾鏁寸悊濡備笅锛?
涓€銆佸湪椤圭洰涔嬪墠锛屽簲璇ョ‘淇濆伐绋嬪笀鐞嗚В浜х敓ANR鐨勫熀鏈師鐞嗭紝Handler鐨勫熀鏈師鐞嗭紝鏄庣櫧涓€浜涗富瑕佸洖璋冨嚱鏁扮殑鎵ц绾跨▼銆傚鏋滃伐绋嬪笀杩樻病杈惧埌杩欎簺瑕佹眰锛屽簲璇ラ€氳繃鍩硅绛夋柟寮忓敖閲忚宸ョ▼甯堜簡瑙h繖浜涚煡璇嗐€?
鍏充簬杩欎簺鎶€鏈殑鐭ヨ瘑鍙弬鑰冦€婂叧浜嶢NR鐨勫畼鏂瑰缓璁€嬪拰銆夾ndroid绾跨▼妯″瀷銆嬪拰銆奓ooper鍜孒andler銆?
浜屻€佸鏋滅▼搴忓湪鍒濆鍖栭樁娈佃緝鑰楁椂锛岃€冭檻鏄剧ず涓€splash灞忔垨鑰呭敖蹇涓昏鍥惧揩閫熸樉绀哄鐞嗭紝鐒跺悗鎵嶆樉绀哄叾浠栫殑瑙嗗浘銆備笉绠℃槸鍝竴绉嶆儏鍐碉紝搴旇璁炬硶琛ㄦ槑绋嬪簭姝e湪寰€鍓嶆墽琛岋紝浠ュ厤鐢ㄦ埛瑙夊緱搴旂敤鍐荤粨浜嗐€?
涓夈€佸湪杩涜鏋舵瀯璁捐鏃讹紝鏋舵瀯甯堝簲璇ュ敖閲忛噰鐢∕VC鏋舵瀯锛屽彟澶栦竴瀹氳娓呮閭d簺浠g爜搴旇鏄湪涓荤嚎绋嬩腑鎵ц锛岄偅浜涗唬鐮佸簲璇ユ槸鍦ㄩ潪涓荤嚎绋嬩腑鎵ц銆傚綋鐒惰鍋氬ソ妗嗘灦涔熶笉瀹规槗鍟婏紒鈯欙箯鈯檅姹楋紒
鍥涖€佸浜庡凡澶勪簬椤圭洰涓悗鏈燂紝鑰屾病鏈夐噰鐢∕VC妗嗘灦锛屾垨鑰呴噰鐢ㄤ簡MVC妗嗘灦浣嗗叾瀹炵幇骞朵笉澶ソ鐨勯」鐩紝搴旇鐢诲嚭鍏舵暣浣撴鏋跺浘锛屾椂搴忓浘绛夎繘琛屽垎鏋愶紝灏介噺閲囩敤杈冨皬鐨勪唬浠凤紝閫愭杩唬鐨勬柟寮忚鍏堕」鐩渶鍚庤揪鍒拌壇濂界殑MVC鏋舵瀯銆傚浜庢垜浠殑褰撳墠椤圭洰锛屾垜姝h瘯鍥句娇鐢ㄨ鏂瑰紡鏉ユ渶澶х▼搴︾殑閬垮厤ANR銆備篃涓嶇煡閬撴渶鍚庤兘涓嶈兘杈惧埌寰堝ソ鐨勬晥鏋溿€?
浜斻€佸湪杩涜缂栫爜鏃讹紝宸ョ▼甯堜竴瀹氳鑰冭檻褰撳墠浠g爜姝诲惁鍦ㄤ富绾跨▼涓墽琛岋紱褰撳墠浠g爜鏄惁鏄€楁椂鎿嶄綔;
绾跨▼瀵归攣鐨勭珵浜夋槸鍚﹀彲鑳介€犳垚浠g爜鐨勭瓑寰咃紝鑰岃€楁椂澶锛涗唬鐮佹槸鍚﹀彲鑳介€犳垚姝婚攣锛岃€屼骇鐢烝NR銆?
鍏€佸鏋滃簲鐢ㄧ▼搴忎腑浣跨敤浜嗙涓夋柟鐨勫簲鐢ㄧ▼搴忥紝璇锋妸杩欎簺绗笁鏂圭殑搴旂敤绋嬪簭鍋氫负鍗曠嫭鐨勮繘绋嬫潵澶勭悊锛屼互閬垮厤瀹冪殑涓嶈壇浠g爜鑰岄€犳垚鏈」鐩嚭鐜癆NR銆傚叧浜庢鎶€鏈鍙傝€冦€夾ndroid涓崟APK搴旂敤澶氳繘绋嬨€?
涓冦€佸湪绋嬪簭杩愯鏃讹紝鍑虹幇浜咥NR锛屽伐绋嬪笀搴旇閫氳繃/data/anr/traces.txt骞剁粨鍚堜唬鐮侊紝杩涜ANR鐨勫垎鏋愩€?
鍏€佸湪椤圭洰涓悗鏈燂紝浣犲彲浠ヤ娇鐢?StrictMode 鏉ュ府鍔╀綘鍦ㄤ富绾跨▼涓煡鎵炬綔鍦ㄧ殑鑰楁椂鎿嶄綔锛屾瘮濡傚缃戠粶鎴栨暟鎹簱鎿嶄綔銆?
涔濄€佸湪椤圭洰鍚庢湡锛屽簲璇ラ€氳繃monkey绛夋潵杩涜鍘嬪姏娴嬭瘯锛屾壘鍑烘綔鍦ㄧ殑ANR锛屽苟杩涜淇敼銆?
鍏充簬monkey鐨勪娇鐢ㄨ鍙傝€冦€夾ndroid鐨刴onkey鐢ㄦ硶銆?
鍗併€佸浜庝竴浜涢噸瑕佺殑ANR鍙婁笉鑹唬鐮侊紝瑕佽繘琛屽綊绾冲拰鎬荤粨锛屽舰鎴愭枃妗o紝浠ヤ究鍒嗕韩缁欏叾浠栫殑鍚屼簨鎴栭」鐩粍锛屽苟浣滀负鏂板憳宸ョ殑鍩硅璧勬枡銆?
鎬荤粨
姣忓綋浜х敓ANR鎴戜滑鍙互鏍规嵁/data/anr/traces.txt鍒嗘瀽瑙e喅锛屼絾杩欎釜椤界柧寰堥毦浠庢牴鏈笂瑙e喅锛屽彧鏈夐€氳繃寮曞叆濂界殑妗嗘灦锛堟瘮濡侻VC妗嗘灦锛夛紝鎻愬崌寮€鍙戝伐绋嬪笀璁ょ煡锛屾妧鏈Н绱幓閬垮厤銆?
[3] Jquery ajva 页面请求 (留言板 交付)
来源: 互联网 发布时间: 2014-02-18
Jquery ajva 页面请求 (留言板 提交)
在struts后台代码
ps: 目前没找到 josn直接转换成 struts 前后java对象的方法?哪位高手可指导下?
<%@ page contentType="text/html; charset=utf-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> <script src="/blog_article/${application.WebResourceUrl }/scripts/global/lib/jquery/addons/jquery.validate-1.7/jquery.validate.js" type="text/javascript" language="javascript"></script> <script type="text/javascript" src="/blog_article/${application.WebResourceUrl }/scripts/global/lib/jquery/core/jquery-1.4.2.min.js"></script> <script type="text/javascript" > function validateForm(){ var check = true; if ($("#msgLinkman").val() == "") { $("#msgLinkman").parent().next().css('color', 'red'); check=false; }else{ $("#msgLinkman").parent().next().css('color', '#999999'); } if ($("#msgMobile").val() == "") { $("#msgMobile").parent().next().css('color', 'red'); check=false; }else{ $("#msgMobile").parent().next().css('color', '#999999'); } if ($("#msgContent").val() == "") { $("#msgContent").parent().next().css('color', 'red'); check=false; }else{ $("#msgContent").parent().next().css('color', '#999999'); } check = false; $("input[type=checkbox]").each(function(){ if($(this).attr("checked")==true || $(this).attr("checked")=='checked'){ $("#msgArea").parent().next().css('display','none'); check=true; return false; }else{ $("#msgArea").parent().next().css({'color':'red','display':'block'}); } }); if($("#msgArea").attr("type")=="text"){ if($("#msgArea").val() == ""){ $("#msgArea").parent().next().css({'color':'red','display':'block'}); check=false; }else{ $("#msgArea").parent().next().css('display','none'); } } return check; } $(function () { $("#ajax_save_msg").click(function () { if(validateForm()==false){ return false; } $.ajax ({ //请求登录处理页 url: "/business/msg/bsn_msg_save_ajax.action", //登录处理页 type: "post", //传送请求数据 data: $("#business_msg").serialize(), success: function (result) { //登录成功后返回的数据 if(result=="success"){ alert("提交成功!"); location.reload(); this } if(result=="error"){ alert("提交失败,请重新提交!"); } } }); }); }); </script> <form id="business_msg" name="business_msg" method="post" action="/blog_article/${application.localDomain}/ucenter/client/bsn_msg_save.action"> <input type="hidden" name="businessMsg.msgReceiveUid" value="${frontBusinessGyDetail.businessGy.usrId}" /> <input type="hidden" name="businessMsg.msgBusinessId" value="${frontBusinessGyDetail.businessGy.gyId}" /> <input type="hidden" name="businessMsg.msgBusinessType" value="gy" /> <dl > <dt>我要留言</dt> <dd> <div > <div > <label><font color="#FF0000">*</font>联系人:</label> <p > <input id="msgLinkman" name="businessMsg.msgLinkman" type="text" onchange="validateForm();"/> </p> <p >请填写您的真实姓名</p> </div> <div > <label><font color="#FF0000">*</font>联系电话:</label> <p > <input id="msgMobile" name="businessMsg.msgMobile" type="text" onchange="validateForm()"/> </p> <p >方便项目负责人与您联系</p> </div> <div > <label>QQ:</label> <p > <input id="msgQq" name="businessMsg.msgQq" type="text" /> </p> <p >请输入您的qq号码</p> </div> <div > <label>电子邮件:</label> <p > <input id="msgEmail" name="businessMsg.msgEmail" type="text" /> </p> <p >请留下您的邮箱地址</p> </div> <div ></div> <div > <label><font color="#FF0000">*</font>希望代理区域:</label> <c:choose> <c:when test="${frontBusinessGyDetail.businessGy.gyArea eq '全国'}"> <p > <input id="msgArea" name="businessMsg.msgArea" type="text" onchange="validateForm()" /> </p> <p >请选择代理地区</p> </c:when> <c:otherwise> <p > <c:forEach items="${fn:split(frontBusinessGyDetail.businessGy.gyArea, ',')}" var="area"> <input id="msgArea" name="businessMsg.msgArea" type="checkbox" value="${area}" onchange="validateForm()"/> ${area} </c:forEach> </p> <p >请选择代理地区</p> </c:otherwise> </c:choose> </div> <div ></div> <div > <label><font color="#FF0000">*</font> 留言信息:</label> <p > <textarea id="msgContent" name="businessMsg.msgContent" cols="" rows="" onblur="validateForm()"></textarea> </p> <p >请输入您的留言信息</p> </div> <div ><a href="#" id="ajax_save_msg">提交留言</a></div> </div> </dd> </dl> <input id="reset" name="" type="reset" /> </form>
在struts后台代码
XXXXX 对象 get/set略。 struts提供的 类型拦截器会自动 赋值给XXX对象 @Action(value = SAVE_AJAX_ACTION) public void save() { PrintWriter pw; try { //这句必须有否则,返回前台的对象是 dom objcet. ServletActionContext.getResponse().setContentType("text/html;charset=UTF-8"); pw = ServletActionContext.getResponse().getWriter(); if(null != businessMsg){ businessMsg.setMsgIp(Util.getConsumerIP(ServletActionContext.getRequest())); businessMsg.setMsgCreated(new Date()); businessMsg.setMsgRead(0); businessMsg.setMsgDelete(0); businessMsg.setMsgDnd(0); businessMsgManager.save(businessMsg); pw.write("success"); }else{ pw.write("error"); } } catch (IOException e) { log.error("bus_msg_save is error!",e); } }
ps: 目前没找到 josn直接转换成 struts 前后java对象的方法?哪位高手可指导下?
最新技术文章: