JSp页面传值和Ext JS表单自动填充

问题描述

有一个JSP文件:Center_right.jsp<body><table border ="1"> <tr><td>题目编号</td><td>题目内容</td><td>题目类型</td><td>选项个数</td><td>选 项</td><td>题目备注</td><td>操作</td> </tr><% while (it.hasNext()) { Questions q=(Questions)it.next(); %><tr> <td><%= q.getQ_id()%></td> <td><%= q.getQ_head()%></td><td><%= q.getQ_type().getQt_des()%></td><td><%= q.getQ_number()%></td><td><%= q.getQ_body()%></td><td><%= q.getQ_remarks()%></td><td><a href ="DesignQuestions/UpdateQuestion.jsp?q_id=<%=q.getQ_id()%>">修改 </a></td><td><a href ="servlet/DeleteQueByIdServlet?q_id=<%=q.getQ_id()%>">删除</a></td></tr><% } list.clear(); %><tr align="center"> <td colspan ="6"><a href ="DesignQuestions/Center_right.jsp?page=1"> 首页</a>||<a href ="DesignQuestions/Center_right.jsp?page=<%=mypage-1%>"> 上一页 </a>||<a href ="DesignQuestions/Center_right.jsp?page=<%=mypage+1%>"> 下一页 </a>||<a href ="DesignQuestions/Center_right.jsp?page=<%=totalpage%>"> 末页 </a></td></tr> </table >修改命令跳转到UpdateQuestion.jsp<script type="text/javascript" src="JS/ext-lang-zh_CN.js"></script><script type="text/javascript">Ext.require([ '*' ]);Ext.onReady(function() {//onReady()函数在页面注册多个函数,依次执行 Ext.QuickTips.init(); Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));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,//reader:reader,//standardSubmit:true,//url:'servlet/AddQueServlet',items : [ {layout : 'form',items : [ {//columnWidth:.7,xtype : 'fieldset',layout : 'form',checkboxToggle : true,//折叠fieldsettitle : '文字输入',autoHeight : true,defaults : {width : 400},defaultType : 'textfield',items : [ {fieldLabel : '题目',name : 'head',allowBlank : false}, {xtype : 'htmleditor',fieldLabel : '题目备注及说明',id : 'editor',anchor : '98%', name : 'remarks', 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(){ //此处可以用myFormPanel.getForm()和myFormPanel.form两种方法获得表单对象. form.getForm().submit({//提交表单数据 url: 'servlet/AddQueServlet',//处理页面,注意返回内容格式的正确性 method: 'post', success: function(form, action) {//保存成功 Ext.Msg.alert('保存成功', action.result.msg); }, failure: function(form, action) {//保存失败 Ext.Msg.alert('保存失败', action.result.msg); } }) ; } },{ text: '重置', handler: function(){ form.form.reset() ;//重置表单 } }]});form.getForm().load({ url: 'DesignQuestions/ShowQueByIdJson.jsp', params: { id: 'load' }, failure: function(form, action) { Ext.Msg.alert("Load failed", action.result.errorMessage); }, success:function(form, action) { Ext.Msg.alert("Load success", action.result.errorMessage); }});var viewport = Ext.create('Ext.Viewport',{ id : 'Center_left', layout : 'fit', autoScroll : true,items : [form]});form.render("form");});</script> </head> <body> <% String qID=request.getParameter("q_id"); session.setAttribute("q_id", qID); //System.out.print(qID); %>这个表单我想要自动填充,从ShowQueByIdJson.jsp获取值:<% int q_id = Integer.parseInt((String)session.getAttribute("q_id"));// 获得页面传递的参数Questions q = new Questions();QuestionsDao questionDao = new QuestionsDaoImpl();q = questionDao.findQuestionsById(q_id);// 调用实现类中根据id查询的方法 %> <% String id = request.getParameter("id") ; if(id!=null &&"load".equals(id)){ %> { success: true, data: { head: "${q.q_head }", remarks: "${q.q_remarks }", number:"${q.q_number }", options: ${q.q_body }" } } <% }else{ %> { success: false, msg: "数据载入错误" } <% } %> 问题来啦!session范围是一个会话,这个q_id传不到ShowQueByIdJson.jsp,所以查不到数据写进JSON字符串,怎样才能达到:点击修改,跳转到表单的页面能够把应该的信息都填充的效果?

解决方案

不对,form.getForm().load({ url: 'DesignQuestions/ShowQueByIdJson.jsp', params: { id: 'load' , q_id:<%=request.getParameter("q_id");%> }, failure: function(form, action) { Ext.Msg.alert("Load failed", action.result.errorMessage); }, success:function(form, action) { Ext.Msg.alert("Load success", action.result.errorMessage); } })
解决方案二:
12.{ 13. success: true, 14. data: { 15. head: "${q.q_head }", 16. remarks: "${q.q_remarks }", 17. number:"${q.q_number }", 18. options: ${q.q_body }" 19. } 20.}这段数据根本就没传到前台去。。要用response.getWriter().write()输出去
解决方案三:
q_id 你传了吗? 呵呵

时间: 2024-08-31 16:55:54

JSp页面传值和Ext JS表单自动填充的相关文章

chrome表单自动填充导致input文本框背景变成偏黄色问题解决

chrome表单自动填充后,input文本框的背景会变成偏黄色的,这是由于chrome会默认给自动填充的input表单加上input:-webkit-autofill私有属性,然后对其赋予以下样式:   复制代码 代码如下: input:-webkit-autofill { background-color: #FAFFBD; background-image: none; color: #000; } 在有些情况下,这个黄色的背景会影响到我们界面的效果,尤其是在我们给input文本框使用图片背

chrome浏览器当表单自动填充时如何去除浏览器自动添加的默认样式_javascript技巧

一.发现该问题的原因-是在写账号登录页面时,input表单添加了背景图片,当自动填充,搓搓的一坨淡黄色背景出来. 这个原因是我草率的直接设置在input元素里面,结果问题就来了.所以如果把这个图标放在input表单外面,就不会出现这个问题. 二.表单自动填充会添加浏览器默认样式怎么处理和避免 第二张图,就是表单自动填充后,chrome会默认给自动填充的input表单加上input:-webkit-autofill私有属性 input:-webkit-autofill, textarea:-web

360极速浏览器如何设置表单自动填充

  360极速浏览器设置表单自动填充的方法如下: 如果已经厌倦了反复填写信息相同的网络表单,请使用只需点击一次即可完成表单填写的自动填充功能,从而节省时间并减少键入内容.如果不想使用自动填充功能,则可以在"自动填充选项"对话框中停用该功能.

jquery php json 表单自动填充代码

这种表单自动完成功能,像百度,google,淘宝他们的搜索功能都有,在用户输入一部要的内容时会根据条件显示相关内容. <script> ;(function($){ /* plugin */ $.fn.autocomplete=function(o){     if(o.ajax) o.ajax=$.extend({ url:'', datatype:'json', async:true }, o.ajax||{});     o.elemcss教程=$.extend({ focus:{'co

使用ext提交表单出错,求大神帮忙

问题描述 使用ext提交表单出错,求大神帮忙 jsp页面代码如下: <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.or

jsp页面传值在spring mvc中的controller中的获取

问题描述 jsp页面传值在spring mvc中的controller中的获取 <% Seller seller =(Seller)session.getAttribute("sellerinfo"); %> <form action="<%=basePath%>plmanage/updateSeller.do" method="post"> <input type="hidden"

两个jsp页面传值获取参数值的问题

问题描述 两个jsp页面传值获取参数值的问题 我有两个jsp页面,A.jap和B.jsp现在A.jsp里面有个链接,单击这个链接需要跳转到B页面并且带一个参数过来.既:点击问题是:我在B.jsp的js或jquery中怎么获取传过来的id.我是新手,求帮助. 解决方案 var s=location.search//这个就是查询参数,就是?问号及后面的东西var m=/id=(d+)/i.exec(s);var id=m?m[1]:'';alert(id); 解决方案二: ${parma.id }

不同jsp页面传值问题!急!!!!!!

问题描述 不同jsp页面传值问题!急!!!!!! 我现在有两个jsp页面,第一个页面中有个下拉框,我想要在第二个页面中当点击按钮时获取第一个页面的下拉框选中的值,应该怎么做. 解决方案 将第一个页面消息传到Session ,在第二个页面获取 解决方案二: 跳到后台存储处理下.再取 解决方案三: 下拉框用change事件触发,用AJAX将值放到后台的这个用户的session中,在另一个页面点击是获取session中的KEY获取你需要的值 解决方案四: js将选中的值传到后台服务器再通过后台服务器去

jsp中提交到Servlet的表单获取的值为什么都为NULL?

问题描述 jsp中提交到Servlet的表单获取的值为什么都为NULL? ------------------addProduct.jsp--------------- <form action="${pageContext.request.contextPath}/servlet/ManagerServlet?operation=addProduct" method="post""> <table width="80%&quo