① java開發站內信問題 求一個很不錯的思路
B/S架構的除了你去向伺服器發送請求,目前還沒有發現你的伺服器可以向客戶端推送的技術.
② 幫我把下面Java寫的站內信的代碼,轉化成c#的,,高手來幫幫我
using System;
//using UserPackage
public class Message {
public static const string STATUS_NEW = "NEW";
public static const string STATUS_READED = "READED";
public static const string STATUS_DELETED = "DELETED";
public static const string STATUS_SENDED = "SENDED";
public static const string STATUS_DELETE_FOREVER = "DELETE_FOREVER";
/**
* @hibernate.id
* generator-class="native"
*/
private int id;
/**
* @hibernate.property
*/
private string title;
/**
* @hibernate.property
*/
private string content;
/**
* @hibernate.property
*/
private string sendStatus;
/**
* @hibernate.property
*/
private string receiveStatus;
/**
* update="false"表示此欄位不更新
* @hibernate.property update="false"
*/
private DateTime createTime;
/**消息發送方
* @hibernate.many-to-one
*/
private User sender;
/**消息接收方
* @hibernate.many-to-one
*/
private User receiver;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public string getTitle() {
return title;
}
public void setTitle(string title) {
this.title = title;
}
public string getContent() {
return content;
}
public void setContent(string content) {
this.content = content;
}
public User getSender() {
return sender;
}
public void setSender(User sender) {
this.sender = sender;
}
public User getReceiver() {
return receiver;
}
public void setReceiver(User receiver) {
this.receiver = receiver;
}
public string getSendStatus() {
return sendStatus;
}
public void setSendStatus(string sendStatus) {
this.sendStatus = sendStatus;
}
public string getReceiveStatus() {
return receiveStatus;
}
public void setReceiveStatus(string receiveStatus) {
this.receiveStatus = receiveStatus;
}
public DateTime getCreateTime() {
return createTime;
}
public void setCreateTime(DateTime createTime) {
this.createTime = createTime;
}
}
注意第二行
③ java頁面回顯錯誤信息。
頁面
<td height="30" class="red"><html:errors property="errors.notlogin" bundle="MessageResources" /></td>
改為:
頁面
<td height="30" class="red"><html:errors property="notlogin" bundle="MessageResources" /></td>
property="notlogin"是你的error key,ActionMessage("errors.notlogin")中才是你配置文件的信息
④ java站內信介面調用文檔怎麼使用
1、調用WebService,對方給出WebService地址,可以用Axis生成對WebService的調用代碼進行調用 2、對方提供介面文檔和傳輸方式,根據介面文檔調用。 Java介面是一系列方法的聲明,是一些方法特徵的集合,一個介面只有方法的特徵沒有方法的實現,...
⑤ java 聊天
對樓主的回帖:
1. java.lang.NullPointerException 空指針異常。看看取值或jsp跳轉是否正確,一般情況之下是由於編程人員的不仔細造成的。
2. 檢查連接資料庫相關的代碼里連接字元
3. 字元串變數未初始化;
4. 介面類型的對象沒有用具體的類初始化
5. 當一個對象的值為空時。
====
但是在你這個問題看來不純是一個簡單的空指針了
你有可能錯誤在:
1.看看有沒有包,在linux下客戶端的測試之下要把項目相對應的包拷貝到linux下。
2.我有JAVA版的聊天室項目,你可以與我取得聯系:[email protected]
註明一下我會查收郵件傳給你。
⑥ 幾道JAVA讀程序題,請高手幫忙看下,最好能稍稍解釋下62643
4題答案:a= 1;b= 2
5題答案:11 0 1
6題答案:12
7題答案:012
不明白答案為什麼是這樣,站內信問我,這里寫太麻煩了
⑦ 誰有論壇上站內信實現jsp structs2源碼啊
import java.io.*;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;
import com.credit.proj.entity.FileForm;
import com.credit.proj.entity.Message;
import com.credit.proj.entity.VMessage;
import com.credit.publicmodel.commons.BaseAction;
import com.credit.publicmodel.commons.Constants;
import com.credit.publicmodel.message.service.MessageService;
import com.credit.publicmodel.permission.security.userDetails.UserInfo;
import com.credit.publicmodel.util.DateUtil;
import com.credit.publicmodel.util.FileUtil;
import com.credit.publicmodel.util.JsonUtil;
/**
* @funciton 消息處理
*
* @author credit004
*
*/
public class MessageAction extends BaseAction implements Constants{
private static final long serialVersionUID = 1L;
private final Log log = LogFactory.getLog(getClass());
private int start;
private int limit;
private MessageService messageService;
// private int msgType;
private String sendToId;
private String piKey;
private String title;
private String content;
private int id;
private int isRead;
// private int processType = 0;
private int msgType;
private String title_S = "";
private int msgType_S = 0;
private String title_SS = "";
private int msgType_SS = 0;
/*文件上傳*/
private File fileUpload;//上傳文件 如若要設置原型的話,請注意
private String fileName;//上傳的名字 如若要設置原型的話,請注意
private String contentType;//上傳的類型 如若要設置原型的話,請注意
private int global_msgId;//附件下載(列表)
private int downId;//下載附件
private int del_msgId;//刪除文件,設置message表 標識
FileForm ff = null;
/**所有新消息*/
public void getAllNewMessage() throws Exception{
UserInfo ui = (UserInfo)this.getSession().getAttribute("userDetails");
String userId = "%,"+String.valueOf(ui.getId())+",%";
int totalNumber = messageService.getReadMessageAmount(userId, 0);
List<VMessage> list = messageService.getUserReadMessageForPages(userId, start, limit,0);
JsonUtil.jsonFromList(list,totalNumber);
}
/**輪詢*/
public int countMessage(){
UserInfo userInfo = (UserInfo)this.getSession().getAttribute("userDetails");
String userId = "%,"+String.valueOf(userInfo.getId())+",%";
int count = messageService.getReadMessageAmount(userId,0);
return count;
}
/**發送消息 jiang*/
public String sendMessage() throws Exception{
Message msg = new Message();
FileForm ff = new FileForm();
UserInfo userInfo = (UserInfo)this.getSession().getAttribute("userDetails");
//上傳文件存儲的名字
String storeFileName = "";
//上傳路徑
String path = "";
// judge
boolean isUploadOk = false;
String sendToId = ","+this.sendToId+",";
/*消息*/
msg.setPiKey(piKey);
msg.setType(msgType);
msg.setTitle(title);
msg.setContent(content);
msg.setCreateTime(DateUtil.getNowDateTime());
msg.setSendTime(DateUtil.getNowDateTime("yyyy-MM-dd (E) HH:mm"));
msg.setSendFrom(userInfo.getId());
msg.setProcessType(Constants.PROCESS_TYPE_BG);
msg.setTakePeople(sendToId);
/*文件上傳 上傳了文件*/
if(fileUpload != null){
storeFileName = "msg"+DateUtil.getNowDateTime("yyyyMMddHHmmssSSS")+FileUtil.getExtention(fileName);
path = "/upload/"+userInfo.getUsername()+"/msg/appendix/"+storeFileName;
String realPath = ServletActionContext.getServletContext()
.getRealPath(path);
File storeFile = new File(realPath);
System.out.println("文件長度="+fileUpload.length());
ff.setContentType(contentType);
ff.setIsDel(0);
ff.setSize(fileUpload.length());
ff.setName(fileName);
ff.setPath(path);
ff.setSendToId(sendToId);
ff.setTitle(userInfo.getName()+" 提供的附件");
ff.setType(1);//1 代表消息上傳附件 待議
ff.setUploaderId(userInfo.getId());
ff.setUpTime(DateUtil.getNowDateTime());
isUploadOk = FileUtil.fileUpload(fileUpload, storeFile, this.BUFFER_SIZE_MSG);
msg.setHasAppendix(1);//設置有附件
if(!isUploadOk){
ff = null;
}
}else{
ff = null;//沒上傳文件
}
messageService.sendMessage(msg,ff);
return null;
}
/**刪除消息 jiang*/
public void delMessage() throws Exception{
messageService.delMessage(id);
id = 0;//使用完後---初始化
}
/**得到詳細信息 jiang*/
public void getDetailMessage() throws Exception{
messageService.getDetailMessage(id);
messageService.readMessage(id, 1);//設置已讀
id = 0;//使用完後--初始化
}
/**設置已讀 作廢 jiang*/
public void readMessage() throws Exception{
log.info("isRead=="+isRead);
}
/**已讀通知 已作廢 jiang*/
public void getReadMesage() throws Exception{
UserInfo ui = (UserInfo)this.getSession().getAttribute("userDetails");
String userId = "%,"+String.valueOf(ui.getId())+",%";
int totalNumber = messageService.getReadMessageAmount(userId,1);
List<VMessage> list = messageService.getUserReadMessageForPages(userId, start, limit,1);
JsonUtil.jsonFromList(list,totalNumber);
}
/**收消息盒子*/
public void getMessageBox() throws Exception{
UserInfo ui = (UserInfo)this.getSession().getAttribute("userDetails");
String userId = "%,"+String.valueOf(ui.getId())+",%";
int isDel = 0;
List<VMessage> list = null;
int totalNumber = 0;
// System.out.println("show me the state"+isRead+processType+msgType);
if(title_S.equals("") && msgType_S == 0){
totalNumber = messageService.getAllMessageAmout(userId, isDel);
list = messageService.getUserMessageForPages(userId, isDel, start, limit);
}else{
String title_S = "%"+this.title_S+"%";
Object[] params = {userId,title_S,this.title_S,msgType_S,msgType_S,};
totalNumber = messageService.getSearchMessageAmount(params);
list = messageService.getUserSearchMessageForPages(params, start, limit);
}
JsonUtil.jsonFromList(list,totalNumber);
}
/**發消息盒子 jiang*/
public void sendMessageBox() throws Exception{
UserInfo ui = (UserInfo)this.getSession().getAttribute("userDetails");
String title_SS = "%"+this.title_SS+"%";
Object[] params = {ui.getId(),title_SS,this.title_SS,msgType_SS,msgType_SS};
//here codes
int totalNumber = messageService.getUserSendMessageAmount(params);
List<VMessage> list = messageService.getUserSendMessageForPages(params, start, limit);
JsonUtil.jsonFromList(list,totalNumber);
}
/*********************************************************************/
/** ################# 附件下載 ##################### **/
/*********************************************************************/
/**附件下載列表*/
public void showDownload() throws Exception{
int isDel = 0;
System.out.println("global_msgId="+global_msgId);
int totalNumber = messageService.getDownloadAmount(global_msgId, isDel);
List<FileForm> list = messageService.getDownload(global_msgId, isDel, start, limit);
JsonUtil.jsonFromList(list,totalNumber);
}
/*********************************************************************/
/**下載--獲得輸入流*/
public InputStream getMsgDownload(){
// FileForm ff = messageService.getFile(downId);
String path = ff.getPath();
System.out.println("ff=="+ff.getPath());
return ServletActionContext.getServletContext().getResourceAsStream(path);
}
/**下載--默認*/
public String msgDownload(){
ff = messageService.getFile(downId);
return "success";
}
/**下載--向struts.xml內傳值 jiang*/
public String getDownloadFileName(){
// FileForm ff = messageService.getFile(downId);
String fileName = ff.getName();
try {
fileName = new String(fileName.getBytes(),"ISO8859-1");
if(ff != null){
return fileName;
}else{
return "";
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return "error";
}
/*********************************************************************/
/**刪除 下載文件---只是在資料庫標識已刪除 jiang*/
public void delMsgDownload() {
String jsonStr = "";
try {
messageService.delFile(downId,del_msgId);
jsonStr = "{success:true}";
JsonUtil.writeJsonString(jsonStr);
} catch (Exception e) {
jsonStr = "{success:false}";
e.printStackTrace();
}finally{
JsonUtil.writeJsonStringNoException(jsonStr);
}
}
/*****回收站*******/
public void delectedMessage() throws Exception{
UserInfo ui = (UserInfo)this.getSession().getAttribute("userDetails");
String userId = "%,"+String.valueOf(ui.getId())+",%";
int totalNumber = messageService.getAllMessageAmout(userId, 1);
List<VMessage> list = messageService.getUserMessageForPages(userId, 1, start, limit);
JsonUtil.jsonFromList(list,totalNumber);
}
/**從資料庫中刪除消息*/
public void removeMessage(){
String jstonStr = "{success:false}";
try {
messageService.removeMessage(id);
jstonStr = "{success:true}";
} catch (Exception e) {
jstonStr = "{success:false}";
e.printStackTrace();
}
JsonUtil.writeJsonStringNoException(jstonStr);
}
/*############################ getter and setters ##########################*/
⑧ 【站內信】user表和message表如何聯立起來怎樣建表好
這樣的需求應該做中間表 用戶表 用戶消息關聯表 消息表
其中用戶消息關聯表 有欄位 uid mid
不明白繼續提問!