spring注入的相关代码

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lys1220/article/details/79514462

自己做记录,其他人勿读,只有自己能看懂

        ServletContext sc =ServletActionContext.getServletContext();
        WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(sc);
        IMiceManager iMiceManager = (IMiceManager)wac.getBean("mice.miceManager");


        //获取请求 URL   
        HttpServletRequest request=ServletActionContext.getRequest();
        HttpServletResponse response  = ServletActionContext.getResponse();

        DoradoContext doradoContext = DoradoContext.getCurrent();
        Long meetingid = new Long(54);
        String tablekey = "MICE_TABLE_KEY_PLAYER";
        MiceTableInfo tblInfo = iMiceManager.getTableInfo(tablekey, meetingid);
        Collection<TableColumnInfo>cols = iMiceManager.getColumnInfosByTableId(tblInfo.getId());

        Collection <MiceMP> mps = iMiceManager.getAllMiceMPs((long)54);
        Iterator<MiceMP> it = mps.iterator();
        Long mpid = (long)0;
        while (it.hasNext()) {
            MiceMP str = it.next();
            mpid = str.getId();
    //      System.out.println(str);
        }

        MicePlayer playerSelf = new MicePlayer();
        playerSelf.setMeetingid((long)54);
        playerSelf.setMpid(mpid);
//      playerSelf.setUname(new String(request.getParameter("name").getBytes("ISO-8859-1"),"utf-8"));
//      playerSelf.setLinkphone(new String(request.getParameter("phone").getBytes("ISO-8859-1"),"utf-8"));
//      playerSelf.setEmail(new String(request.getParameter("province").getBytes("ISO-8859-1"),"utf-8"));
//      playerSelf.setNote(new String(request.getParameter("city").getBytes("ISO-8859-1"),"utf-8"));
        playerSelf.setUname(request.getParameter("name"));
        playerSelf.setLinkphone(request.getParameter("phone"));
        playerSelf.setEmail(request.getParameter("province"));
        playerSelf.setNote(request.getParameter("city"));

        iMiceManager.modifyMicePlayer(playerSelf);

        //返回给页面,通知报名成功
        response.setContentType("text/html" + ";charset=UTF-8");
        response.setCharacterEncoding("UTF-8");
        String msg = "success";
        response.getWriter().write(msg);

        response.getWriter().flush();
        response.getWriter().close();
   jsp端代码
        //提交数据
       // var url = "../dream/apply.htm";
        var url = "miceApply.action";
        var param = {
                "phone" : userphone,
                "name" : username,
                "province" : province,
                "city" : city
    //            "email" : '',
     //           "dealer" : distributor,
    //            "choosedrive":1
            };
        $.post(url,param,function(data){
            if(data == 'success') {
                //alert('报名成功');
                $('.screen1').fadeOut();
                $('.screen2').fadeIn();
                $('#username').val('');
                $('#userphone').val('');
                //$('#usermail').val('');
                $('#user-distributor').val('')
                $('#user-city2').val('')
                $('#user-province').val('');
            }else {
                alert("报名失败!");
            }
        });

自己做记录,其他人勿读,只有自己能看懂

阅读更多
换一批

Spring注入

11-21

我想在Spring中注入,通过启动,加载一个类,然后掉相应的方法,最后要在一个类里面连接数据库查询。rn现在已经度配置文件,加载都通过了,就是在查询时rn有以下异常:rnorg.springframework.orm.hibernate3.HibernateQueryException: unexpected token: = near line 1, column 72 [ from com.citic.platform.service.dao.hibernate.bo.Dictionarywhere dicid='9000']; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: = near line 1, column 72 [ from com.citic.platform.service.dao.hibernate.bo.Dictionarywhere dicid='9000']rnCaused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: = near line 1, column 72 [ from com.citic.platform.service.dao.hibernate.bo.Dictionarywhere dicid='9000']rn at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)rn at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)rn at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)rn at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:258)rn at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)rn at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)rn at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:77)rn at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:56)rn at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)rn at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)rn at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)rn at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)rn at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:842)rn at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)rn at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:840)rn at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:832)rn at com.citic.platform.service.dao.hibernate.HibernateService.getObjects(HibernateService.java:35)rn at com.citic._9000client.service.util.TradeConfig.getConfig(TradeConfig.java:186)rn at com.citic._9000client.service.impl.PlatCall9000Impl.initConn(PlatCall9000Impl.java:54)rn at com.citic.common.method.LogServlet.init(LogServlet.java:31)rn at javax.servlet.GenericServlet.init(GenericServlet.java:212)rn at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)rn at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)rn at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:448)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:552)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)rn2008-11-21 10:19:28 org.apache.coyote.http11.Http11BaseProtocol start

没有更多推荐了,返回首页