首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

-返回前一个页面

2013-06-26 
求助----返回前一个页面这是个弹窗,在这里进行后台验证,弹出下面的提示后怎么返回这个弹窗呢?代码在这里:p

求助----返回前一个页面
-返回前一个页面
这是个弹窗,在这里进行后台验证,弹出下面的提示后怎么返回这个弹窗呢?-返回前一个页面


代码在这里:
public ModelAndView addStory(HttpServletRequest req, HttpServletResponse res){
HashMap model = new HashMap();

String[] tagids = req.getParameterValues("tagid");
String[] ftagids = req.getParameterValues("ftagid");
String sid = (req.getParameter("sid")==null)?"":req.getParameter("sid");
String  content=(req.getParameter("content")==null)?"":req.getParameter("content");
String  forumTitle=(req.getParameter("forumTitle")==null)?"":req.getParameter("forumTitle");
String  u_tag=(req.getParameter("u_tag")==null)?"":req.getParameter("u_tag");
String  mfilepath=(req.getParameter("mfilepath")==null)?"":req.getParameter("mfilepath");
String ip=mytools.getIpAddr(req);
long ipAddr =mytools.ipToLong(ip);
TbUserOperaLog log =new TbUserOperaLog();
String remark="";
String location ="/storyList.do";
HttpSession session = req.getSession();
TbUser user = (TbUser)session.getAttribute("_currentUser");
if(user==null | session==null){
String msg="請先登錄!";
model.put("msg", msg);
if(!sid.equals("")){
model.put("location", "/forumList.do?sid="+sid);
return new ModelAndView(this.showMessageView,model);
}
model.put("location", location);
return new ModelAndView(this.showMessageView,model);
}
TbForumPost tbForumPost = new TbForumPost ();
tbForumPost.setContents(content);
if(mfilepath==""){
tbForumPost.setIsphoto(0);
}else{
tbForumPost.setIsphoto(1);
}
tbForumPost.setTitle(forumTitle);
tbForumPost.setTypeid(Integer.parseInt(ObjectType.ForumPost.getCode()));

tbForumPost.setUid(user.getId());
tbForumPost.setStatus(Integer.parseInt(AuditStatus.Auditing.getCode()));
tbForumPost.setIsgood(0);
tbForumPost.setReplies(0);
tbForumPost.setClick_num(0);
tbForumPost.setLast_ip(ipAddr);
tbForumPost.setLast_r_time(new Date());
tbForumPost.setCreateTime(new Date());

int fcount = forumPostService.addForumPost(tbForumPost);

if(fcount>0 ){
if(!mfilepath.equals("")){
TbPhotoPath tp =  new  TbPhotoPath();
tp.setCreateTime(new Date());
tp.setP_path(mfilepath);
tp.setStatus(Integer.parseInt(AuditStatus.Auditing.getCode()));
int ppcount = photoPathService.addPhotoPath(tp);

if(ppcount>0){
TbPhotoRelation tr = new TbPhotoRelation();
tr.setCreateTime(new Date());
tr.setObject_type(Integer.parseInt(PhotoObjectType.ForumPostPhoto.getCode()));
tr.setPhoto_id(ppcount);
tr.setObject_id(fcount);
photoRelationService.addPhotoRelation(tr);
}
log.setUid(user.getId());
log.setCreatetime(new Date());
Date date =new Date();
log.setIp(ipAddr);
log.setOperate(Integer.parseInt(UserOper.ForumPublish.getCode()));
remark=user.getAccount()+"于"+date+"添加了論題《"+forumTitle+"》";
log.setRemark(remark);
userOperaLogService.addUserOperaLog(log);


}

/*if(!url.equals("")){
TbPhotoPath tp =  new  TbPhotoPath();
tp.setCreateTime(new Date());
tp.setP_path(url);
tp.setStatus(Integer.parseInt(AuditStatus.Auditing.getCode()));


int ppcount = photoPathService.addPhotoPath(tp);

if(ppcount>0){
TbPhotoRelation tr = new TbPhotoRelation();
tr.setCreateTime(new Date());
tr.setObject_type(Integer.parseInt(PhotoObjectType.ForumPostPhoto.getCode()));
tr.setPhoto_id(ppcount);
tr.setObject_id(fcount);
}
}*/

TbTag tag = new TbTag();
String tg="";
String[] tagarr= u_tag.split(",");
if(tagarr.length>=2 && tagarr.length<=3){
for(int i=0;i<tagarr.length;i++){
if(tagarr[i].length()<=20 && tagarr[i].length()>0){
tg=tagarr[i].trim();
boolean a=tagService.isExist(tg);
if(a){
tag.setTag(tg);
List<TbTag> tgList=tagService.getTagList(tag, "id desc", 1, 10);
if(tgList.size()>0){
tag.setId(tgList.get(0).getId());
tag.setUse_num(tgList.get(0).getUse_num()+1);
tagService.modifyTag(tag);
}

}else{
tag.setTag(tg);
tag.setCreatetime(new Date());
tag.setType(2);
tag.setClick_num(0);
tag.setUse_num(1);
tag.setStatus(2);
int tagid=tagService.addTag(tag);
if(tagid>0){
TbTagRelation tagRelation =new TbTagRelation();
tagRelation.setTagid(tagid);
tagRelation.setObject_type(Integer.parseInt(TagObjectType.ForumPostTag.getCode()));
tagRelation.setObject_id(fcount);
tagRelation.setTagtype(2);
tagRelation.setCreatetime(new Date());
tagRelationService.addTagRelation(tagRelation);

log.setUid(user.getId());
log.setCreatetime(new Date());
Date date =new Date();
log.setIp(ipAddr);
log.setOperate(Integer.parseInt(UserOper.TagPublish.getCode()));
remark=user.getAccount()+"于"+date+"手工添加了標籤《"+tg+"》";
log.setRemark(remark);
userOperaLogService.addUserOperaLog(log);
}
}

}
if(tagarr[i].length()>20){
model.put("msg", "標籤長度不能超過20!");
model.put("location", location);
return new ModelAndView(this.showMessageView,model);
}
}
}
if(tagarr.length>3){

model.put("msg", "最多只能輸入三個標籤!");
model.put("location", location);
return new ModelAndView(this.showMessageView,model);
}
if(tagarr.length<2){

model.put("msg", "至少輸入2個標籤!");
model.put("location", location);
return new ModelAndView(this.showMessageView,model);
}
if(ftagids==null){
model.put("msg", "至少選擇一個固定父標籤!");
model.put("location", location);
return new ModelAndView(this.showMessageView,model);
}

if(ftagids!=null){
for(String f : ftagids){
if(!f.equals("")){
TbTagRelation ttr = new TbTagRelation();
//ttr.setCreatetime(new Date());
ttr.setObject_id(fcount);
ttr.setObject_type(Integer.parseInt(ObjectType.ForumPost.getCode()));
ttr.setTagid(Integer.parseInt(f));
ttr.setTagtype(1);
List<TbTagRelation>ttrList = tagRelationService.getTagRelationList(ttr, "id desc", 1, 1);
if(ttrList.size()>0){
}else{
ttr.setCreatetime(new Date());
tagRelationService.addTagRelation(ttr);


}
TbTag tag2 =tagService.getTagById(Integer.parseInt(f));
TbTag tag1 = new TbTag();
if(tag2.getUse_num()==null){
tag1.setUse_num(1);
}else{
tag1.setUse_num(tag2.getUse_num()+1);
}
tag1.setClick_num(0);
tag1.setType(1);
tag1.setId(Integer.parseInt(f));
tagService.modifyTag(tag1);

log.setUid(user.getId());
log.setCreatetime(new Date());
Date date =new Date();
log.setIp(ipAddr);
log.setOperate(Integer.parseInt(UserOper.TagPublish.getCode()));
remark=user.getAccount()+"于"+date+"使用了 固定標籤《"+tag2.getTag()+"》";
log.setRemark(remark);
userOperaLogService.addUserOperaLog(log);
}
}
}


model.put("msg", "發表成功,請等候管理員審核!");
model.put("location", location);
return new ModelAndView(this.showMessageView,model);
}else{
model.put("msg", "操作失敗");
model.put("location", location);
return new ModelAndView(this.showMessageView,model);
}
}
真心求助 java 返回前一个页面
[解决办法]
弹出失败信息后,直接输出javascript代码history.go(-1) 
[解决办法]

引用:
这位同学,你的校验应该由页面来完成啊,像什么输入框有没有填写这些信息都应该在js里校验,通过了才跳转到后台代码的,你这种想法不合理,如果真的有复杂的信息需要校验,那也是通过ajax去异步到后台进行判断然后返回页面处理通过ajax回调的结果才决定是否跳到别的后台代码或者页面,这是正途如果ajax不了解,http://blog.csdn.net/xxjxxmxhlr/article/details/9014313看看这个你就会了,history.go(-1) 这种东西个人建议不要用有时候浏览器会有缓存问题,如果是单纯的想有个返回上一页面的操作就自己做个按钮重新申请这样安全

楼上正解

热点排行
Bad Request.