window.location.href = "sendMsg.jsp?checkDate=" + 1; 不执行。。。。。
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="com.macchy.m2.server.plugin.bbs.*"
contentType="text/html; charset=UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language="javaScript" src="js/sendBbs.js"></script>
</head>
<%
//title
final String TITLE = "txttitle";
//content
final String CONTENT = "txtcontent";
//session user
final String SESSINOUSER = "sessionUser";
//sessin group
final String SESSIONGROUP = "sessionGroup";
//session NickName
final String SESSIONNICKNAME = "sessionNickName";
//sessin WidgetName
final String SESSIONWIDGETNAME = "sessionWidgetName";
//empty
final String EMPTY = "";
//title
String title = "";
//content
String content = "";
//user
String user = "";
//groupName
String groupName = "";
//nickName
String nickName = "";
//widgetName
String widgetName = "";
SmartUpload su = new SmartUpload();
try {
su.setCharset("UTF-8");
su.initialize(pageContext);
su.setMaxFileSize(1000000000);
su.setTotalMaxFileSize(20000000);
su.setAllowedFilesList("doc,txt,java,jpg,png,zip,pdf,rar,jar,html,jsp,xls,mp3,gif");
su.setDeniedFilesList("exe,mid,waw,bat,htm");
su.upload();
} catch (Exception e) {
response.sendRedirect("sendMsg.jsp?checkDate=" + 4);
return;
}
//post title get
title = su.getRequest().getParameter(TITLE);
// post content get
content = su.getRequest().getParameter(CONTENT);
// session user get
user = (String) session.getAttribute(SESSINOUSER);
// session group get
groupName = (String) session.getAttribute(SESSIONGROUP);
//session nickName get
nickName = (String) session.getAttribute(SESSIONNICKNAME);
// session nickName get
widgetName = (String) session.getAttribute(SESSIONWIDGETNAME);
if(title.equals(EMPTY) && !content.equals(EMPTY)) {
%>
<script type="text/javascript">
window.location.href = "sendMsg.jsp?checkDate=" + 1;
</script>
<%
} else if (!title.equals(EMPTY) && content.equals(EMPTY)) {
response.sendRedirect("sendMsg.jsp?checkDate=" + 2);
return;
} else if (title.equals(EMPTY) && content.equals(EMPTY)) {
response.sendRedirect("sendMsg.jsp?checkDate=" + 3);
return;
}
String fileName = su.getFileName();
BbsSendData send = new BbsSendData();
String filePath = send.doPost(title, content, user, groupName, fileName, nickName, widgetName);
if(fileName != null || !fileName.equals(EMPTY)) {
su.save(filePath);
}
response.sendRedirect("showMsg.jsp");
%>
</html>
window.location.href = "sendMsg.jsp?checkDate=" + 1;
不执行。。。。
如何解决
[解决办法]
if(title.equals(EMPTY) && !content.equals(EMPTY)) { %> <script type="text/javascript"> window.location.href = "sendMsg.jsp?checkDate=" + 1; </script> <% }
------解决方案--------------------
语法没有问题啊。
是不是压根就没进到这里阿?
要不你在
window.location.href = "sendMsg.jsp?checkDate=" + 1;
前面加上
alert();
看到底有没有执行这段代码。
[解决办法]
if(title.equals(EMPTY) && !content.equals(EMPTY)) {
%>
这个条件是TRUE吗?
[解决办法]
可能是lz整个页面的编码问题操作的
那段js是不是从其他页面复制过来的? 如果是的话就是编码原因造成的。解决:手工写这样一段代码在本页面
如果不是上面的原因的话,那么检查一下看看那里多“ 之类的
用切块的方式来跟踪,一块一块跟踪,肯定会找到那段有问题而影响到js了