哎!没人理啊!我还是自己搞定吧!在url前边加上standardSubmit:true,就可以跳转啦!######把配置文件贴出来, 你这是 在做什么? 详细描述清楚######
楼主啊,你这是急着赶公交呢还是急着交差啊?是不是做不出来就要被老板辞退啊,要不然怎么这么急。。
什么都不说,错误信息一贴就问。我把我大腿伸出来给你看,问“你猜猜我同桌今天打麻将赢了多少钱”。。
你回答啊。。简直莫名其妙 ######
AddQuestionsServlet 这个servlet有问题啊######好大的凶兆,好凶啊!我不是急吗?就赶紧提了错误。其实啊,我现在也不晓得到底是哪里错啦!我就又重新进了一个servlet,把
AddQuestionsServlet里的内容粘过来,重启MyEclipse就OK啦!不过谢谢你们的关注!######
不过又出现一个新问题:center_left.jsp,内容是Ext的一个form表单,
url:'servlet/AddQueServlet', 具体如下:
<script type="text/javascript">
Ext.require([ '*' ]);
Ext.onReady(function() {//onReady()函数在页面注册多个函数,依次执行
Ext.QuickTips.init();
Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));
// NOTE: This is an example showing simple state management. During development,
// it is generally best to disable state management as dynamically-generated ids
// can change across page loads, leading to unpredictable results. The developer
// should ensure that stable state ids are set for stateful components in real apps.
Ext.state.Manager.setProvider(Ext
.create('Ext.state.CookieProvider'));
//表单组合控件在中间部分的左侧
var form = new Ext.form.FormPanel({
labelAlign : 'right',
autoScroll : true,
labelWidth : 50,
width : 600,
// title: 'form',
frame : true,
url:'servlet/AddQueServlet',
items : [ {
layout : 'form',
items : [ {
//columnWidth:.7,
xtype : 'fieldset',
layout : 'form',
checkboxToggle : true,//折叠fieldset
title : '文字输入',
autoHeight : true,
defaults : {
width : 400
},
defaultType : 'textfield',
items : [ {
fieldLabel : '题目',
name : 'head',
allowBlank : false
}, {
xtype : 'htmleditor',
fieldLabel : '题目备注及说明',
id : 'editor',
anchor : '98%',
name : 'des',
fontFamilies: ["宋体", "隶书", "黑体","Times New Roman"]
}, {
xtype : 'hidden',
name : 'hidden'
} ]
}, {
//columnWidth:.3,
xtype : 'fieldset',
checkboxToggle : true,
title : '数据验证',
autoHeight : true,
defaultType : 'checkbox',
hideLabels : true,
layout : 'column',
name:'checkValue',
//style: 'margin-left:10px;',
//bodyStyle: 'margin-left:20px;',
items : [ {
boxLabel : '必填',
columnWidth : .125,
name : 'check',
inputValue : '1',
checked : true,
width : 'auto'
}, {
boxLabel : '手机号码',
columnWidth : .125,
name : 'check',
inputValue : '2',
//checked: true,
width : 'auto'
}, {
boxLabel : '邮编',
columnWidth : .125,
name : 'check',
inputValue : '3',
width : 'auto'
}, {
boxLabel : '身份证号',
columnWidth : .125,
name : 'check',
inputValue : '4',
width : 'auto'
}, {
boxLabel : '日期',
columnWidth : .125,
name : 'check',
inputValue : '5',
width : 'auto'
}, {
boxLabel : 'Email',
columnWidth : .125,
name : 'check',
inputValue : '6',
width : 'auto'
}, {
boxLabel : '必答题',
columnWidth : .25,
name : 'check',
inputValue : '7',
width : 'auto'
} ]
}, {
xtype : 'fieldset',
checkboxToggle : true,
title : '选项(每行一个)',
autoHeight : true,
defaultType : 'textarea',
hideLabels : true,
layout:'form',
//style: 'margin-left:10px;',
//bodyStyle: 'margin-left:20px;',
items : [ {
xtype:'textfield',
fieldLabel : '输入选项个数',
name : 'number'
},{
width : 400,
grow : true,
name : 'options',
//allowBlank : false,
emptyText : '输入选项',
maxLength : 10,
minLength : 2
} ]
}, {
xtype : 'fieldset',
//checkboxToggle:true,
title : '选项排列',
autoHeight : true,
defaultType : 'radio',
hideLabels : true,
layout : 'column',
//style: 'margin-left:10px;',
//bodyStyle: 'margin-left:20px;',
items : [ {
boxLabel : '横向',
name : 'rank',
inputValue : '1',
//checked: true,
width : 'auto'
}, {
boxLabel : '竖向',
name : 'rank',
inputValue : '2',
checked : true,
width : 'auto'
} ]
} ]
} ], buttons: [{
text: '保存',
handler:function(){
form.getForm().submit();
}
},{
text: '读取'
},{
text: '取消'
}]
});
var viewport = Ext.create('Ext.Viewport',
{
id : 'Center_left',
layout : 'fit',
autoScroll : true,
items : [form]
});
form.render("form");
});
</script> AddQueServlet如下:
public class AddQueServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
doPost(request, response);// 调用doPost方法
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;utf-8");
response.setCharacterEncoding("utf-8");
// 获得表单提交的参数
String head=request.getParameter("head");
String des=request.getParameter("des");
int number=0;
if(request.getParameter("number")!=""){
number= Integer.parseInt(request.getParameter("number"));
}
//System.out.print(number+"###################");
String body=request.getParameter("options");
String checkValue[]= request.getParameterValues("check");
int rank=Integer.parseInt(request.getParameter("rank"));
//System.out.print(rank+"###################");
HttpSession session=request.getSession();
//int qt_id = Integer.parseInt((String)session.getAttribute("qt_id"));// 获得所选问题类型的ID
//System.out.print(qt_id);
int qt_id =1;
QuestionType qType = new QuestionType();
QuestionTypeDao questionType = new QuestionTypeDaoImpl();
qType = questionType.findQueTypeById(qt_id);
Questions question = new Questions();
question.setQ_head(head);
question.setQ_body(body);
question.setQ_type(qType);
question.setQ_number(number);
QuestionsDao questionsDao = new QuestionsDaoImpl();
questionsDao.add(question);// 调用实现类的的添加方法
response.sendRedirect("../DesignQuestions/Center_right.jsp");// 重定向到显示全部的Servlet中
}
}
问题就是:Center_right.jsp无法显示,在表单里点击保存后,页面不跳转,也不报错!大侠们,说说答案吧
######web.xml里这个Servlet配置正常否?
AddQuestionsServlet ######
引用来自“王瑞平”的答案
web.xml里这个Servlet配置正常否?
AddQuestionsServlet
不是
AddQuestionsServlet 是AddQueServlet,以下是XML的配置: <servlet-mapping>
<servlet-name>AddQueServlet</servlet-name>
<url-pattern>/servlet/AddQueServlet</url-pattern>
</servlet-mapping> 我觉得没什么问题啊?求教
######就是这里的错误######错哪里啦?您给指出来啊!