📄 contentaction.java.back2
字号:
package com.gzrealmap.oa.actions;
/**
* <p>Title: 基本类库</p>
* <p>Description: 基本类库</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: 广州瑞图(gzrealmap.com)</p>
* @author charlse
* @version 1.0
*/
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;
import com.gzrealmap.lib.webupload.WebUpload;
import com.gzrealmap.archive.actions.*;
import com.gzrealmap.oa.*;
import java.util.*;
import org.apache.commons.fileupload.*;
import com.talent.Dem.common.*;
import com.gzrealmap.lib.log.*;
public class ContentAction {
private ContentAction() {
}
private static Log log = Log.getInstance(ContentAction.class);
public static String showInnerNewsContent(HttpServletRequest request) throws
Exception {
String ID = request.getParameter("ID");
String content = "";
if (ID != null) {
String sql = "SELECT content FROM innerNews where id='" + ID + "'";
com.gzrealmap.lib.jdbc.JDBCUtil theJDBCUtil = com.gzrealmap.lib.jdbc.
JDBCUtil.
getInstance();
theJDBCUtil.connect();
ResultSet rs = theJDBCUtil.query(sql);
if (rs.next()) {
content = rs.getString(1);
}
rs.close();
theJDBCUtil.disconnect();
}
return content;
}
public static void downloadInnerNewsImage(HttpServletRequest request,
HttpServletResponse response) throws
Exception {
com.gzrealmap.lib.jdbc.JDBCUtil theJDBCUtil = com.gzrealmap.lib.jdbc.
JDBCUtil.
getInstance();
String ID = request.getParameter("ID");
if (ID != null) {
String sql = "SELECT acc FROM innerNews where id='" + ID + "'";
theJDBCUtil.connect();
ResultSet rs = theJDBCUtil.query(sql);
if (rs.next()) {
response.setContentType("image/jpeg;charset=GB2312");
ServletOutputStream out = response.getOutputStream();
out.write(rs.getBytes(1));
out.flush();
out.close();
}
rs.close();
theJDBCUtil.disconnect();
}
}
public static void deployInnerNews(HttpServletRequest request) throws
Exception {
OaTime theOaTime = new OaTime();
WebUpload upload = WebUpload.getInstance(request);
String topic = (upload.getFieldValue("topic"));
String content = (upload.getFieldValue("content"));
String sender = upload.getFieldValue("txtID");
String send_time = theOaTime.getDate("-") + " " + theOaTime.getTime();
String end_time = upload.getFieldValue("end_time");
com.gzrealmap.lib.jdbc.JDBCUtil theJDBCUtil = com.gzrealmap.lib.jdbc.
JDBCUtil.getInstance();
Enumeration enum = upload.getFileItems();
if (enum.hasMoreElements()) {
FileItem item = (FileItem) enum.nextElement();
// String filename = FileUtils.getFileName(item.getName());
try {
theJDBCUtil.connect();
theJDBCUtil.setAutoCommit(false);
String sql = "select * from innerNews where 1=2";
ResultSet rs = theJDBCUtil.queryforUpdate(sql);
rs.moveToInsertRow();
rs.updateString("topic", topic);
rs.updateString("content", content);
rs.updateString("send_from", sender);
rs.updateString("send_time", send_time);
rs.updateString("end_time", end_time);
rs.updateBytes("acc", item.get());
rs.updateString("type", "innernews");
rs.insertRow();
theJDBCUtil.commit();
}
catch (Exception ex) {
log.error(ex);
theJDBCUtil.rollback();
throw ex;
}
finally {
theJDBCUtil.disconnect();
}
}
}
public static void deployForum(HttpServletRequest request) throws Exception {
ActionsUtil.processRequest(request);
com.gzrealmap.lib.jdbc.JDBCUtil theJDBCUtil = com.gzrealmap.lib.jdbc.
JDBCUtil.getInstance();
String topic = request.getParameter("txttopic");
String content = request.getParameter("txtcontent");
String userid = request.getParameter("txtID");
String sql = "select * from forum where 1=2";
try {
theJDBCUtil.connect();
theJDBCUtil.setAutoCommit(false);
ResultSet rs = theJDBCUtil.queryforUpdate(sql);
rs.moveToInsertRow();
rs.updateString("topic", topic);
rs.updateString("content", content);
rs.updateString("send_from", userid);
rs.updateTimestamp("send_time",
new Timestamp(new java.util.Date().getTime()));
rs.insertRow();
theJDBCUtil.commit();
}
catch (Exception ex) {
log.error(ex);
theJDBCUtil.rollback();
throw ex;
}
finally {
theJDBCUtil.disconnect();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -