后台用这种方式返回数据到ftl,有问题吗,list为什么取不到值

@RequestMapping(value = "/project/p_list.do", method={RequestMethod.POST, RequestMethod.GET})
public ModelAndView login(HttpServletRequest request, HttpServletResponse response) throws Exception {
ModelAndView mv = new ModelAndView("test2");

    String token = request.getParameter("token");
    String page = request.getParameter("page");
    String upStatu=request.getParameter("upStatu");
    String statu=request.getParameter("statu");

    String loginUrl = "http://10.0.2.14:8080/zfs_pg/project/p_list.do?";
    String url = loginUrl + "token="+ token ;//+ "&page=" + page + "&upStatu=" + upStatu + "&statu=" + statu; 

    String result = null;
    try {
        result = HttpUtils.URLPost(url);
    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace(); 
    }
    System.out.println(result);

    JSONObject  jsonObject = new JSONObject(result);
    int ret = jsonObject.getInt("ret");
    List<Project> pList = new ArrayList<Project>();
    if(ret==0){ 
        JSONObject  jsonObject2 = jsonObject.getJSONObject("data");
        JSONArray plist = jsonObject2.getJSONArray("plist"); 

        for (int i = 0; i < plist.length(); i++) {
            JSONObject pC = plist.getJSONObject(i);
            int pid = pC.getInt("pid");
            String title = pC.getString("title");
            String content = pC.getString("content");
            String type = pC.getString("type");
            String pTime = pC.getString("pTime");
            String endTime = pC.getString("endTime");
            String uName = pC.getString("uName");
            Project pc = new Project();
            pc.setPid(pid);
            pc.setContent(content);
            pc.setTitle(title);
            //pc.setpTime(pTime);
            pList.add(pc);
        }           
    }else{
        String msg = jsonObject.getString("msg");
    }



    mv.addObject("plist", pList);
    return mv;

}

2个回答

freemarker取数据时,先判断是否为空。

在后台输出测试一下

hanhx1993
匿名用户123 后台数据获取到了,就是对freemarker不熟,不知道这么传值可以吗,怎么取值
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
后台返回JSON 前台取不到值
我ASP.NET后台返回的值是这样的:rnJSON:rn[code=csharp]rnResponse.Write(rn"\"FileJson\":[\"f_FileName\":\"测试文件.rar\",\"f_FileSize\":\"3.4\",\"f_FileUrl\":\"201208345945.rar\",\"f_FileName\":\"说明.doc\",\"f_FileSize\":\"1.2\",\"f_FileUrl\":\"201305082983.doc\"]");rnrn[/code]rn前台这样取rn[code=javascript]rn $.ajax(rn url: 'MyData.aspx',rn type: 'POST',rn data: type: 1, Id: Id ,rn dataType: 'json',rn timeout: 100000,rn error: function () alert('请求出错~~~!'); ,rn success: function (result) rn var json = eval(result); rn var str = "";alert(json);rn for (var i = 0; i < json.length; i++) rn rn //alert(json[i].f_FileName);rn str += json[i].f_FileName + "-" + json[i].f_FileSize + json[i].f_FileUrl;rn str += "\r\n";rn rn alert(str);rn rn );rn[/code]rnalert出来的全是空值,什么也没有,是哪里错了?
为什么取不到值?
String b="5";rnString a="gz='"+b+"'"; //让用户自定义得来的要更新的字段rnString sql="update tab set '+a+'; // 想把gz字段值更新成5rncon1.executeUpdate(sql); //执行后gz字段值更新不成功rn如何加以改正?rnrn
为什么取不到值
<%@ page contentType="text/html;charset=gb2312" %>rn<%@ page language="java" import="java.sql.*" %>rnrn<%!rn public String getStr(String str)rn rn tryrn rn String temp_p=str;rn byte[] temp_t=temp_p.getBytes("ISO8859-1");rn String temp=new String(temp_t);rn return temp;rn rn catch(Exception e)rn rn e.printStackTrace();rn rn return null;rn rn rn%>rn<%! //处理输入的信息内容rn //该函数能够将字符串sstr中的'\n'、'\r'转换为 ;rn //也能够将字符串sstr中的转换为%nbsp;;rn public static String returnTobr(String sstr)rn rn if(sstr==null||sstr.equals(""))rn rn return sstr; rn rn StringBuffer sTmp=new StringBuffer();rn int i=0;rn while(i<=sstr.length()-1)rn rn if(sstr.charAt(i)=='\n'||sstr.charAt(i)=='\r')rn rn sTmp=sTmp.append(" ");rn rn else if(sstr.charAt(i)==' ')rn rn sTmp=sTmp.append(" ");rn rn elsern rn sTmp=sTmp.append(sstr.substring(i,i+1));rn rn i++;rn rn String s1=sTmp.toString();rn return s1;rn rn%>rn<%! //处理输入的信息内容rn //该函数能够将字符串sstr中的'<'转换为"<";rn //能够将字符串sstr中的'>'转换为">";rn public static String returnTohtml(String sstr)rn rn if(sstr==null||sstr.equals(""))rn rn return sstr;rn rn StringBuffer sTmp1=new StringBuffer();rn int i=0;rn while(i<=sstr.length()-1)rn rn if(sstr.charAt(i)=='<')rn rn sTmp1=sTmp1.append("<");rn rn else if(sstr.charAt(i)=='>')rn rn sTmp1=sTmp1.append(">");rn elsern rn sTmp1=sTmp1.append(sstr.substring(i,i+1));rn rn i++;rn rn String s2=sTmp1.toString(); rn return s2;rn rn%>rn<%! //定义变量rn String author,title,content;rn%>rn<% rn if(session.getAttribute("username")!=null)rn rn author=(String)session.getAttribute("username");rn rn title=returnTobr(returnTohtml(request.getParameter("title")));rn content=returnTobr(returnTohtml(request.getParameter("content")));rn rn author=getStr("author");rn title=getStr("title");rn content=getStr("content");rn rn%>rn<% //执行数据库操作,发布新的帖子rn String sqlinsert="insert into sendnew(author,title,content)";rn sqlinsert=sqlinsert+"Values('"+author+"','"+title+"','"+content+"')";rn workM.executeQuery(sqlinsert);rn%>rn rn rn rn rn<% //显示用户名rnif(session.getAttribute("username")!=null)rnout.println(session.getAttribute("username"));rnrn%> 当前位置:首页 -> 论坛 -> 发表新言论成功rn rn rn rn rn 返回个性论坛rn 返回java论坛rn rn rn
为什么取不到值?????
aspx文件: rn<%@ Page Language="C#" AutoEventWireup="true" CodeFile="demo.aspx.cs" Inherits="demo" %> rnrn rnrn rn rn 无标题页 rn rn rn rn rn rn rn rn rn rn rn rncs文件: rnusing System; rnusing System.Data; rnusing System.Configuration; rnusing System.Collections; rnusing System.Web; rnusing System.Web.Security; rnusing System.Web.UI; rnusing System.Web.UI.WebControls; rnusing System.Web.UI.WebControls.WebParts; rnusing System.Web.UI.HtmlControls; rnrnpublic partial class demo : System.Web.UI.Page rn rn protected void Page_Load(object sender, EventArgs e) rn rn if(HiddenField1.Value!="") rn Label1.Height = Unit.Pixel(int.Parse(HiddenField1.Value));//为什么取不到值 rn rn rnrn为什么我得到HiddenField1.Value为空!
List一个对象取不到值
为什么打印出来的都是null呀,list一个对象 应该怎么赋值呀?rnrn[code=Java]rn private List callingTypes;rnrn…………rnrn rs = stmt.executeQuery("select * from idl_ticket_match_d order by SORT_KEY DESC");rnrn callingTypes=new ArrayList();rn while (rs.next()) rn callingTypes.add(new CallingType(rs.getString("PHONE_HEAD"), rsrn .getString("SRC_TICKET_TYPE")));rn System.out.println(rs.getString("PHONE_HEAD"));//这样是有值的,所以问题应该在这个list上rn rnrn for(int i=0;i
后台返回数据问题。。 List>
![图片说明](https://img-ask.csdn.net/upload/201703/01/1488337180_394359.png)rn前台接收的是这种格式的。![图片说明](https://img-ask.csdn.net/upload/201703/01/1488336944_198710.png)rn![图片说明](https://img-ask.csdn.net/upload/201703/01/1488336954_381928.png)rn我应该怎么赋值到id上啊?
liferay后台取不到值
当在网页上进行表单提交后,后台取不到值,显示为null解决方法: 1.在网页上添加到name属性中。 2.在liferay-portlet.xml文件中添加false (一般放在下)
JSF后台取不到值
process属性写的是table的id,解决的办法:<table>外面加上<p:panel>
前台用script赋的值,为什么在后台取不到?
前台代码:rnfunction imgSrc()rnrn var number1=Math.floor(Math.random() * (4))+1;rn timeString1 = 'images/'+number1+'.gif'; rn document.getElementById('img1').src=timeString1;rnrnwindow.onload = imgSrc;rnrn然后我随便拖一个Web控件,会报错"类型“Button”的控件“Button1”必须放在具有 runat=server 的窗体标记内。"rn但是我form有runat=server,button也有。rnrn只能拖HTML按钮,加runat=server,rn后台代码:rnResponse.Write(img1.ID+img1.Src);没有用。
请问这句SQL有问题吗,为什么取不到数据
select distinct a.fundcode,a.fundnameabbr,a.pinyincode from tb_fundarchive a ,tb_fundnetvalue b where rna.isdeleted = 0 and a.fundtype = 7 and a.fundcode = b.fundcodernand (a.fundcode like '%021%' or a.pinyincode like '%021%' or a.fundname like '%021%' or a.fundnameabbr like '%021%')
为什么取不到数据
数据库中的存储过程是rnALTER proc UTC_GetMingxiBaobiaorn(rn @UTC_MingXi_Cust varchar(50),rn @UTC_MingXi_State int,rn @UTC_MingXi_date varchar(20),rn @UTC_MingXi_Accuser varchar(30)rn)rnasrnselect h.UTCid,h.PhoneNo,h.CustCode,h.CustName,convert(varchar(10),h.Rectime,120) as Rectime,rn h.Flag,convert(varchar(10),h.Acctime,120) as Acctime,h.Accuser,d.ArtCode,d.Quantity,a.ArtName rnfrom utc_header as h join utc_detail as d rnon(h.UTCid = d.UTCid) join utc_article as arnon(d.artcode=a.artcode)rnwhere (@UTC_MingXi_Cust is null or CustCode = @UTC_MingXi_Cust) rn and (@UTC_MingXi_State=3 or Flag = @UTC_MingXi_State)rn and (@UTC_MingXi_date is null or @UTC_MingXi_date = convert(varchar(10),Acctime,120))rn and (@UTC_MingXi_Accuser ='ALL' or Accuser = @UTC_MingXi_Accuser)rnrnrnrnrnrnrn程序代码是rnprotected void Button1_Click(object sender, EventArgs e)rn rnrn SqlParameter[] workParam = new SqlParameter[4];rn workParam[0] = new SqlParameter("@UTC_MingXi_Cust", SqlDbType.NVarChar);rn workParam[0].Direction = ParameterDirection.Input;rn workParam[0].Value = "350944";rnrn workParam[1] = new SqlParameter("@UTC_MingXi_State", SqlDbType.Int);rn workParam[1].Direction = ParameterDirection.Input;rn workParam[1].Value = 3;rnrn workParam[2] = new SqlParameter("@UTC_MingXi_date", SqlDbType.NVarChar);rn workParam[2].Direction = ParameterDirection.Input;rn workParam[2].Value = "2009-05-07";rnrn workParam[3] = new SqlParameter("@UTC_MingXi_Accuser", SqlDbType.NVarChar);rn workParam[3].Direction = ParameterDirection.Input;rn workParam[3].Value = "萧山清点员";rnrn rn DataSet ds = new DataSet();rn DataBaseM DBM = new DataBaseM();rn ds = DBM.RunProc("UTC_GetMingxiBaobiao", workParam, ds); rnrn if (ds.Tables[0].Rows.Count == 0)// 执行这一句rn rn Response.Redirect("Nodata.aspx");rn rn ReportViewer1.Visible = true;rnrn ReportDataSource rds = new ReportDataSource("DataSetmingxi_UTC_GetMingxiBaobiao", ds.Tables[0]);rn ReportViewer1.LocalReport.DataSources.Clear();rn ReportViewer1.LocalReport.DataSources.Add(rds);rnrn ReportViewer1.LocalReport.Refresh();rnrnrnrn在查分器中执行rnexec UTC_GetMingxiBaobiao '35044',3,'2009-05-07','萧山清点员' 有数据返回rnrn
为什么取不到SESSION变量的值?
在注册SESSION变量的页面是这样写的:rn$username = $HTTP_POST_VARS["username"];rnsession_register("username");rnrn在另一个页面这样判断:rnif(!isset($_SESSION["username"]) || $_SESSION["username"]=="")rnrn print ("username unregistered! ");rn print ("Login ");rn die();rnrnelse print ("username is registered! ");rnrnrn $HTTP_POST_VARS["username"]已经有值了,但是在判断的页面中打印出来的却是username unregistered!,这是为什么?rnrnPHP的版本是4.3.9,是不是PHP的配置文件还要做什么修改?
为什么我取不到值?
如果用sql数据库。total=rs("optiona")+rs("optionb")+rs("optionc")rn这段代码对不对,如果对,为什么我取不到total的值?
这样为什么取不到值?
rnrnrn.aspx 中这样写 ImageUrl='<%# Eval("video_photo") %>' 这个就正常,但PostBackUrl='player.aspx?id=<%# Eval("video_id") %>' 就不能得到video_id字段的值,这是为什么?rnrn有什么办法实现以上功能?
在DataGrid为什么取不到值
在DataGrid页脚中加入新行:rnprivate void 费用报销申请表_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)rn rn if(e.CommandName=="add1")rn rn tryrn rn string yy=((TextBox)e.Item.Cells[0].Controls[1]).Text;rn string fsrq=((TextBox)e.Item.Cells[1].Controls[1]).Text.Trim();rn string fyje=((TextBox)e.Item.Cells[2].Controls[1]).Text;rn string pjzs=((TextBox)e.Item.Cells[3].Controls[1]).Text;rn string error;rn if(new objCharge().添加费用报销申请表(bh.Text,yy,fsrq,fyje,pjzs,out error))rn rn rn rn elsern rn Response.Redirect("../Error.aspx?error="+error);rn rn rn catch(Exception ex)rn rn Response.Redirect("../Error.aspx?error="+ex.Message);rn rn rnrn==============================================================================rn为什么yy,fsrq,fyje,pjzs都取不到值,是代码有错误吗?
request.getParameter("")为什么取不到值
页面上一个连接rnhttp://localhost:8080/aaa.do?curKeyIndex=2rnrnaaa.do里rn public ActionForward execute(rn ActionMapping mapping,rn ActionForm form,rn HttpServletRequest request,rn HttpServletResponse response) rnString curKeyIndex = request.getParameter("curKeyIndex");//rnrncurKeyIndex老是取到null值。不知道什么原因?大家帮我看看。
为什么取不到@Mj的值????
create proc GetMj(@Gg nvarchar(20),@Zs int,@Mj decimal(10,2) output)rnasrn beginrn declare @sql nvarchar(500)rn set @sql='select '+replace(@Gg,'"','*2.54')+'*'+cast(@Zs as nvarchar)rn exec sp_executesql @sql,N'@a int output',@Mj outputrn endrnrndeclare @a decimal(10,2)rnexec GetMj '20"*10',1,@a outputrnselect @arnrn为什么取不到@Mj的值?
为什么Dso.XMLDocument.documentElement取不到值?
我的代码如下:rnrnrnJS:rnrn function addItems()rn tryrn rn var itemsRoot = ItemsDso.XMLDocument.documentElement;(总也取不到,不知道为什么。)rn var newnode= itemsRoot.childNodes.item(0).cloneNode(true);rn rn catch(e)rn alert("error:"+e);rn rnrnItemsDso.XMLDocument,返回是"",ItemsDso.XMLDocument.documentElement就抛出异常了。rn我用的是MyEclipse4.1,Eclipse的版本是3.1rn
User.Identity.Name为什么取不到值?
FormsAuthentication.GetAuthCookie(LoginStr[1].Trim(), false);rn这个已经成功了,但User.Identity.Name为什么取不到值?
为什么总是取不到值
EXTJS 取不到后台aspx的值?总是显示是0条rnrn[code=JScript]rn Ext.onReady(function() rn //Ext.BLANK_IMAGE_URL = "Resources/Images/default/s.gif"; rn var dstore = new Ext.data.JsonStore(rn url: "getDepartment.aspx",rn fields: ["Name", "Code"],rn root: 'rows'rn );rn dstore.load();rnrnrn var dateSelect = new Ext.form.FormPanel(rn height:500,rn title: "日期选择",rn labelSeparator: ':',rn labelWidth: 60,rn labelAlign: "right",rn width: 600,rn applyTo: 'dateSelect',rn items: [rn new Ext.form.DateField(rn id: 'dfSelect',rn format: 'Y年m月d日',rn minValue: '1900-01-01',rn maxValue: '3000-01-01',rn disabledDaysText: '禁止选择该日期',rn fieldLabel: '选择日期',rn width: 150,rn showToday: truern ),rnrn new Ext.form.ComboBox(rn id: "cbDepartment",rn fieldLabel: "部门",rn triggerAction: "all",rn store: dstore,rn valueField: "Code",rn displayField: "Name",rn //mode: "local",rn forceSection: true,rn typeAhead: true,rn resizeAble: truern ),rnrn new Ext.form.HtmlEditor(rn id: 'htmlContent',rn width: 500,rn autoHeight: false,rn fieldLabel: "HTML编辑"rn )rn ]rn );rn Ext.MessageBox.alert("Test the return record num", "共获得" + dstore.getCount() + "条数据");rnrn );rn[/code]rnrn后台aspxrn[code=C#]rnusing System;rnusing System.Data;rnusing System.Configuration;rnusing System.Collections;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Web.UI.HtmlControls;rnrnpublic partial class getDepartment : System.Web.UI.Pagernrn protected void Page_Load(object sender, EventArgs e)rn rn string result = null;rn result = "rows:['Name':'开发部', 'Code':'1', 'Name':'销售部', 'Code':'2', 'Name':'行政部', 'Code':'3', 'Name':'质检部', 'Code':'4']";rn HttpContext.Current.Response.ContentType = "text/plain";rn HttpContext.Current.Response.Write(result);rn //Response.Write(result);rnrn rnrnrn[/code]
为什么取不到值呢
JSP代码:rn employee emp=new employee();rn String temp=emp.getEmployeeId(Type,keyword);//这里type=admin keyword=namern String EmpId[]=temp.split(",");rn int len=EmpId.length;rn out.print(temp);//为什么输出为空rn类employee :rnpublic String getEmployeeId(String type,String keyword) throws Exceptionrn String EmpId="";rn Connection conn;rn String sql="select Employee_Id from employee_record where '"+type+"' like '"+keyword+"'";rn db=new database();//连数据库的rn conn=db.dbconnect();/连数据库的rn Statement stmt=conn.createStatement(); rn ResultSet rs=stmt.executeQuery(sql);rn while(rs.next())rn int i=rs.getInt(1);rn EmpId=EmpId+String.valueOf(i);rn rn return EmpId;rn rn这里的temp输出为空rn而数据库里的name字段是有admin的rn为什么呢
为什么我取不到值。
rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrnprivate void dgdDepartSet_ItemCommand(object source, rnSystem.Web.UI.WebControls.DataGridCommandEventArgs e)rn rn string[] strDepartArray="",""; rn string strDepartName,strErrorMsg,strInsert;rn int intDepartID;rn if(e.CommandName=="AddDepart")rn rn strDepartArray[0]=((TextBox)e.Item.FindControl("txtDepartID")).Text.Trim();rn strDepartArray[1]=((TextBox)e.Item.FindControl("txtDepartName")).Text.Trim();rn rn Response.Write("AA"+strDepartArray[0]);rnrnrn为什么取不到txtDepartID里用户录入的值。都是空!
为什么e.Item.BackColor取不到值
这是aspx文件dataGrid代码rnrnrnrnrnrnrnrnrnrnrnrn<%# GetRegistertype(DataBinder.Eval(Container, "DataItem.REGISTERTYPE")) %>rnrnrnrnrnrnrnrnrnrnrnrnrnrnrn这是vb的事件代码rnrn Private Sub Grid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles Grid.ItemDataBoundrn If e.Item.ItemType = System.Web.UI.WebControls.ListItemType.Footer Or e.Item.ItemType = System.Web.UI.WebControls.ListItemType.Header Or e.Item.ItemType = System.Web.UI.WebControls.ListItemType.Pager Thenrn Returnrn End Ifrnrnrn e.Item.Attributes.Add("onMouseOver", "this.style.backgroundColor='#ccffcc';")rn e.Item.Attributes.Add("onMouseOut", String.Format("this.style.backgroundColor='#0';", Hex(e.Item.BackColor.ToArgb())))rn End Sub
为什么取不到值?(RowDataBound)
if (e.Row.RowType == DataControlRowType.DataRow)rnrn//明明有值,可就是取不到。就是显示为空。但整个gridview显示正常rn DDL_Select.Items.Add(e.Row.Cells[1].Text) rnrngridview的信息参见rn========================================================rnrnrnrnrnrnrnrnrn=================================================
为什么取不到xmlnode 的值??
rn zhangsanrn shanghairn zhangsna@322.netrn sssrnrnrn sssrn ssrn ss@22.netrn asfdasfdrnrnrnrnXmlDocument oXml = new XmlDocument();rnXmlNodeList oNodes;rnXmlNode oNode;rnoXml.Load("DataSet.xml");rn rnoNodes = oXml.DocumentElement.SelectNodes("//User");rnfor (int i = 0; i < oNodes.Count; i++)rnrn oNode = oNodes[i];rn MessageBox.Show( oNode.SelectSingleNode("//Name").InnerText;rnrnrn为何每次取到的值都一样的???rn
为什么取不到object.style.property的值?????
rn然后定义一个rn rn在javascript里想取T1.style.padding,alert一下,是空.rn其他属性也不行.但是如果rn rn这样再取T1.style.padding的值就是4px了,不知道为什么.现在的实际情况不太允许用第二种情况,有什么办法解决呢???rnrn
为什么取不到checkbox的值
前后台代码都在这里,请帮我解决谢谢rn [code=C#] rn rn rn 公司设置rn rnrnrnrnrn rn rn rn 序号rn 公司名称rn 操作rn 选择rn rnrn rn <%# Container.ItemIndex + 1 %>rnrn <%#DataBinder.Eval(Container.DataItem, "SFL_Org_Name")%>rn ">修改 | ">删除rn rn rnrnrnrnrn rn rn rn rn rnrn [/code]rnrnrnrn[code=C#]public partial class Hr_Default : System.Web.UI.Pagernrn BLL.main Org = new BLL.main();rn Model.Org sqlstr = new Model.Org();rn protected void Page_Load(object sender, EventArgs e)rn rn if (!Page.IsPostBack)rn rn comDatabind();rn rn rn public void comDatabind()rn rn sqlstr.sqlOrg = "SELECT * FROM SFL_Org";rn DataSet ds = Org.getOrg(sqlstr);rn comList.DataSource = ds;rn comList.DataBind();rn rn protected void Button2_Click1(object sender, EventArgs e)rn rn StringBuilder sb = new StringBuilder();rn foreach (RepeaterItem item in comList.Items)rn rn CheckBox check = (CheckBox)item.FindControl("Chk");rn if (check != null)rn rn if (check.Checked == true)rn rn sb.Append(check.Checked.ToString());rn sb.Append(",");rn rn rn rn Response.Redirect(sb.ToString());rn rn[/code]
为什么取不到session的值!
一、service层代码:rn//根据dao 和bean 层来的;上面两层没问题rn//查询全部rn public List getDepts()rn //做为测试使用rn List list=new ArrayList();rn list.add(new Dept(10,"开发部","北京"));rn list.add(new Dept(20,"测试部","上海"));rn list.add(new Dept(30,"客户部","深圳"));rn list.add(new Dept(40,"销售部","西安"));rn return list;rn rn二、在action层中取到service的方法rn private DeptService deptService=new DeptService();rn public void doGet(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn //获取用户提交的请求,确定调用逻辑层的方法rn List depts=deptService.getDepts();rn //封装数据到访问范围内rn HttpSession session=request.getSession();rn session.setAttribute("depts",depts);rn rn //跳转页面rn response.sendRedirect("dept.jsp");rn rn三、jsp页面:rn<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"rn%>rn<%@ page import="com.cc.bean.Dept" %>rn<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>rnrnrn rn My JSP 'dept.jsp' starting pagern rn rn我是页面rn rn $d.deptno| $d.dname| $d.loc rn rn rn rn rnrnrn四、页面:http://localhost:8080/JSTL/dept.jsp, 什么都没传过来
Cookies为什么取不到值?
Response.Cookies["smscontent"].Value = content.Text.ToString().Trim();rn Response.Cookies["smsusr"].Value = TextBox1.Text.ToString().Trim();rnrn这是前一个页面上的rnrn后一个页面为什么TEXTBOX还是空的?是不是取不到值?rnrn TextBox1.Text= Request.Cookies["smsusr"].Value;rn content.Text= Request.Cookies["smscontent"].Value;
为什么我的值取不到
我有一个图片上传rnrnrn 图片上传rn rnrnrnrnrnrnrnrnrn在这document.form1.send.value实际上是图片的名字.为什么会取不到,请教一下
为什么取不到textbox的值?
var var1; rnvar1 = document.Form1.textboxid.Value;rnalert(var1);rnrn用rnvar1 = document.all.textboxid.Value;rnvar1 = document.Form1.textbox1.Text;rn都不行rn
为什么QueryString取不到值?
我在WebForm1.aspx.vb中,添加了一个Button,并为其click事件添加了事件方法,如下所示:rn Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Clickrnrn '不同的用户给相应的页面rn If TextBox1.Text = "1" Thenrn Response.Write(" ")rn ElseIf TextBox1.Text = "2" Thenrn Response.Write(" ")rn ElseIf TextBox1.Text = "3" Thenrn Response.Write(" ")rn ElseIf TextBox1.Text = "4" Thenrn Response.Write(" ")rn End Ifrn Response.Write(" ")rn End Subrn大家注意这一句话:rnResponse.Write(" ")rnrn我在这里添加了参数“page=frame1”rnrn可是我在另外一个页面中调用str = Request.QueryString("page")时,发现str为空,这是怎么回事啊?是不是在frame中不能添加参数呢?
为什么函数取不到值?
rnrn为什么文本框没有显示传递的dvalue1和dvalue2的值?rnvalue=dvalue1 这一句写错了吗?
为什么取不到值??晕了
class.iamge.php:rnmDB = new mysql;rn rn rn function uploadFiles($up,$upload,$pEmail)rn rn $minSize=1;rn $maxSize=10000;rn $imagePath="./images/";rn rn $type=substr(strrchr($up['name'],"."),1); rn $type9=substr(strrchr($upload['name'],"."),1); rn $type1="jpg"; rn $type2="gif"; rnrn if ((strcmp($type,$type1)) and (strcmp($type,$type2))and(strcmp($type9,$type1)) and (strcmp($type9,$type2))) rn rnrn exit( " ");rn rnrn rn if(!$up['size']<$minSize && !$upload['size']<$minSize)rn rn if($up['size'] >$maxSize && $upload['size']>$maxSize) rn rn echo " ";rn return false;//返回值rn rn else rn rn rn $str=explode(".",$up['name']);rn $str1=explode(".",$upload['name']);rn rn $sql="select user_id from member where email = '$pEmail'";rn $result = $this->mDB->query($sql);rn rn $row = $this->mDB->fetchArray($result);rn rn $pUserId = $row[user_id];rn $upname=$pUserId."_s".$str[1];rn $uploadname=$pUserId."_l".$str[1];rn rn $upfile = $imagePath.$upname;rn $uploadfile = $imagePath.$uploadname;rn if( copy($up['tmp_name'],$upfile) && copy($upload['tmp_name'],$uploadfile))rn rn echo " ";rn $this->insertInto($upname,$uploadname,$pEmail);rn return true;//返回值rn rn elsern rn echo " ";rn return false;//返回值rn rn rn rn rn rn function insertInto($up,$upload,$pEmail)rn rn rn $sql="update member set photo='$up',photo2='$upload' where email='$pEmail'";rn rn return $this->mDB->query($sql);rn rn rn rn function updateImage($pUpimage,$pUpimage2,$pEmail)rn rn $sql="update member set photo='$pUpimage',photo2='$pUpimage2'";rn return $this->mDB->query($sql);rn rn rn rn rn rn rn function getImage($pUserId)rn rn $sql = "select photo,photo1 from member where user_id='$pUserId'";rn $result = $this->mDB->query($sql);rn if($row = $this->mDB->fetchArray($result))rn rn $this->mPhoto = $row["photo"];rn $this->mPhoto1 = $row["photo1"];rn return true;rn rn elsern return false;rn rn rn /**rn *生成缩略图rn */rn function getResizedPic ($srcFile, $dstFile, $dstW, $dstH)rn rn $data = GetImageSize($srcFile,&$info);rn rn rn switch ($data[2]) //$giforjpg = $data[2];rn rn case 1:rn $im = ImageCreateFromGIF($srcFile); rn break;rn case 2:rn $im = imagecreatefromjpeg($srcFile); rn break;rn rn rnrn $srcW = ImageSX ($im);rn $srcH = ImageSY ($im);rn $dstX = 0;rn $dstY = 0;rn rnrn if ($srcW * $dstH > $srcH * $dstW) rn rn $fdstH = round ($srcH * $dstW / $srcW); rn $dstY = floor (($dstH - $fdstH) / 2);rn $fdstW = $dstW;rn rn else rn rn $fdstW = round ($srcW * $dstH / $srcH); rn $dstX = floor (($dstW - $fdstW) / 2);rn $fdstH = $dstH;rn rn rnrn $ni = ImageCreate ($dstW, $dstH);rn $dstX = ($dstX < 0) ? 0 : $dstX;rn $dstY = ($dstX < 0) ? 0 : $dstY;rn $dstX = ($dstX > ($dstW / 2)) ? floor ($dstW / 2) : $dstX;rn $dstY = ($dstY > ($dstH / 2)) ? floor ($dstH / 2) : $dstY;rn rnrn $black = ImageColorAllocate ($ni, 238, 238, 238); //填充的背景色你可以重新指定,我用的是#EEEEEErn imagefilledrectangle ($ni, 0, 0, $dstW, $dstH, $black);rn ImageCopyResized ($ni, $im, $dstX, $dstY, 0, 0, $fdstW, $fdstH, $srcW, $srcH);rn rn if($data[2] == 2)rn ImageJpeg ($ni); //如果你要把图片直接输出到浏览器,那么把第二个参数去掉,并用header()函数指定mine类型rn elsern ImageGif ($ni); //rn rnrn imagedestroy ($im);rn imagedestroy ($ni);rn chmod ($dstFile, 0755);rn return true;rn rn //header('Content-Type: image/jpeg');rn rnrn rn?> rnrnregister.php:rnrn.....rnif($user->addUser($username,$nickname ,$birthday,$gender ,$gameid,$city ,$jointime,$bloodtype ,$avoirdupois,$bodilyform ,$oicq,$icq,$msn,$userintro ,$toevery,$gameroll,$constellation,$email,$province,$love,$address,$zip))rn rn rn rn if($image->uploadFiles($photo,$photo1,$email))rn $user->addPassword($username,$password);rn rn echo " ";rn rn rn elsern echo " ";rnrn问题:在调用$image->uploadFiles($photo,$photo1,$email))时,$photo,$photo1的值并没有传到函数中,请各位指教!
为什么ViewState取不到值?
以前只知道ViewState可以像Session一样使用,只是ViewState不可以跨页面.可是今天我就是在一个页面中取ViewState的值,怎么也取不到,换成Session就可以取到.为什么啊?下面是我写的测试代码.是通过ViewState把传递的数字都联起来rnrnaspx代码如下:rnrn rn rn 1 rn 2 rn 3 rn 4 rn 5 rn 6 rn rn rnrnrn.cs代码如下:rnrn protected void Page_Load(object sender, EventArgs e)rn rnrn //if (!IsPostBack)rn //rn if (ViewState["ViewNum"] == null)rn rn ViewState["ViewNum"] = "无";rnrn rn elsern rn ViewState["ViewNum"] = ViewState["ViewNum"].ToString() + "," + Request.QueryString["Num"];rn rnrn Response.Write("ViewState=" + ViewState["ViewNum"] + " ");rn rn //rn rnrn无论怎样,读出的ViewState值都是"无",传递的参数Request.QueryString["Num"]接收不到.请高手帮忙了
为什么取不到内存值?
Public Class Form1 rn Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal hwnd As String, ByVal lpText As String) As Integer rn Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Integer, ByRef lpdwProcessId As Integer) As Integer rn Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer rn Public Const PROCESS_ALL_ACCESS = &H1F0FFF rn Public Declare Function ReadProcessMemory Lib "kernel32.dll" ( _ rn ByVal hProcess As Integer, _ rn ByVal lpBaseAddress As Integer, _ rn ByRef lpBuffer() As Byte, _ rn ByVal nSize As Integer, _ rn ByRef lpNumberOfBytesWritten As Integer) As Integer rn Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer rn rn rn Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click rn Dim jb As Integer rn Dim pid As Integer rn Dim hProcess As Integer rn Dim bufferr(10) As Byte rn Dim readnumber As Integer rn jb = FindWindow("Sword3 Class", Nothing) rn GetWindowThreadProcessId(jb, pid) rn hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid) rn ReadProcessMemory(hProcess, &HC0890C0, bufferr, bufferr.Length, readnumber) rn TextBox1.Text = System.Text.Encoding.Default.GetString(bufferr)//错在这,提示“数组不能为空” rn rn我在 局部变量 里看到,bufferr的值为Nothing, rn为什么??
菜鸟问题,EXTJS的文件类型,在后台用Request取不到值
代码如下: rn id : 'UploadLogo', rn autoScroll : false, rn xtype : 'textfield',rn fieldLabel:'本地上传',rn name : 'file', rn hideLabel : true,rn autoCreate : rn tag : "input", rn type : "file", rn size : "20", rn autocomplete : "off", rn onChange : "Ext.get('UploadLogofile').dom.value=Ext.get('file').dom.value;" rn rn rnrn去掉type : "file", 这一行变成纯粹的文本框,就可以取到,但小弟我是做上传功能,请高手帮帮忙
jquery.ajax 回到函数取不到后台返回的值
框架用的是s+struts2+irnajax取不到response.getWriter() .writer 中的值 直接调用后台方法浏览器显示:"likes":"9874645464564","comments":"9874645464564" 但是再success中的msg显示的是null。。 rnrn前台 ajax方法rnrnvar url="http://192.168.200.112:8090/mimi/dynamic/queryDynamicByTest";rn jQuery.ajax(rn type: "get",rn url: url,rn data: "share="+paramentStr,rn dataType: "json" ,rn success: function(msg)rn var data=eval('(' + msg + ')');rn var mp4=jQuery("#mp4");rn /* ma4.attr( rn src: data., rn alt: "Test Image" rn rn ); */ rn rn rn );rnrnrn后台方法:rnpublic String queryDynamicByTest()rn Map map=this.getDynamicService().queryDynamicById(dynamicId);rn map =new HashMap();rn map.put("likes", "9874645464564");rn map.put("comments", "9874645464564");rn String content = super.renderToJson(map);rn System.out.println("=====================test= "+content);rn HttpServletResponse response = ServletActionContext.getResponse();rn //response.setContentType("text/json;charset=utf-8");rn response.setCharacterEncoding("UTF-8");rn try rn response.getWriter().print(content);rn catch (IOException e) rn rn return null;rn
取 List 值的问题
开发环境:Struts2.0rn主要想实现的功能:使用Struts标签取得Java类中返回的List对象中的值。rnrnJava代码:rnrnprivate List list_step;rnrnpublic List getList_step() rn return list_step;rnrnpublic void setList_step(List list_step) rn this.list_step = list_step;rnrnrnpublic String contentStep() throws Exceptionrn DBConn dbconn = new DBConn(); //自定义的类,主要功能是取得数据库连接,执行SQL语句取得类型为Resultset的结果集rn ResultSet rs1 = null;rn tryrn rs1 = dbconn.ExeQuery("Select * from view_step_bookinfo"); //dbconn.ExeQuery()是自定义类DBConn中的方法rn list_step = resultSetToList(rs1); // rn catch (SQLException ex) rn System.err.println("makeItemHtmlStr.executeQuery:" + ex.getMessage());rn finallyrn dbconn.CloseConn();rn rn rn return "success";rnrnrnpublic List resultSetToList(ResultSet rs) throws Exception rn if (rs == null)rn return Collections.EMPTY_LIST;rn rn ResultSetMetaData md = rs.getMetaData();rn List list = new ArrayList();rn Map rowData;rn int columnCount = md.getColumnCount();rn rn while (rs.next()) rn rowData = new HashMap(columnCount); rn for (int i=1;i<=columnCount;i++) rn rowData.put(md.getColumnName(i),rs.getObject(i)); rn rn list.add(rowData); rn //System.out.println( "list: " + list.toString()); rn rn return list; rnrnrnJSP代码:rnrnrn ...rn ...rnrnrnrn问题是:rn 1.不知道Java代码是否正确,List对象能够传到JSP中来,是不是需要使用Map来传递,如果需要该怎么实现?rn 2.JSP中的代码如何实现?中value值"#left_step"和"$left_step"有何区别?我取得的List结果集中字段名不确定,取某一行值的方法是什么,比如:left_step.Index[0].toString;之类的。rnrn对于高手来说这个问题很简单,还请高手不吝赐教。
关于select的问题,为什么取不到值?
test.jsprn==============rn<%@ page contentType="text/html; charset=gb2312" language="java" import="java.util.*" errorPage="" %>rnrnrn rn rnrnrnrn rn rn rn rnrnfason 1rnfason 2rnfason 3rnfason 4rnfason 5rnfason 6rnrnrn rnrn rnrnrn rnrnrnrnrnrnrnrnrn rn rnrnrnrn==============================rnsearch.jsprn==============================rn<%@ page contentType = "text/html; charset=GB2312" import="java.util.*" %>rnrnrnrn New Document rnrnrnrn<%rnEnumeration eNames = request.getParameterNames();rn while(eNames.hasMoreElements()) rn String strName = (String)eNames.nextElement();rn out.println("strName=" + strName + " ");rn String[] strValues = request.getParameterValues(strName);rnrn for(int i=0; i");rn rn rn%>rnrnrnrn=================rn为什么得不到右边select框里的内容.如何解决???????
相关热词 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池 c#5.0 安装程序 c# 分页算法 c# gmail 发邮件 c# 多层文件