当前位置: 代码迷 >> J2EE >> 寻宗师:SSH中,页面传值给action中,查询结果报错
  详细解决方案

寻宗师:SSH中,页面传值给action中,查询结果报错

热度:110   发布时间:2016-04-21 21:59:50.0
寻大师:SSH中,页面传值给action中,查询结果报错:

页面代码:
<script type="text/javascript">
     function selectSid()
     {
        var sid = document.getElementById("sid").value;
        window.location.href="findBySidStudent?sid="+sid;
     }
  </script>
<body>
      请输入 学生学号:<input id="sid" type="text" name="t_44kwssb.sid"><br/>
 
    <input type="button" value="提交" onclick="selectSid()"/>
    <input type="reset" value="重置" />
   
   
  </body>

action方法:   属性sid,已经加了get set方法       
         public String doFindBySid() throws Exception{
     Model model=modelService.findSid(sid);//学号
     ActionContext ac =ActionContext.getContext();
     request=(Map<String,Object>)ac.get("request");
        request.put("model", model);
        return Constant.SUCCGET;
    }

service方法:
       public Model findSid(int sid) {
    String hql ="from Model as c where = c.sid = '"+sid+"' ";
    
     return  modeldao.findSid(hql);
        }

页面错误代码:
HTTP Status 500 - unexpected token: = near line 1, column 33 [from Model.as c where = c.sid = '5' ]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: = near line 1, column 33 [from Model.as c where = c.sid = '5' ]
type Exception report

message unexpected token: = near line 1, column 33 [from Model as c where = c.sid = '5' ]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: = near line 1, column 33 [from model as c where = c.sid = '5' ]

description The server encountered an internal error that prevented it from fulfilling this request.

exception 

org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: = near line 1, column 33 [from model as c where = c.sid = '5' ]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: = near line 1, column 33 [from model as c where = c.sid = '5' ]

------解决方案--------------------
String hql ="from Model as c where = c.sid = '"+sid+"' "

这个拼错了。 where后面的=  是什么情况
------解决方案--------------------
查询语句语法问题,仔细检查一下。
------解决方案--------------------
SQL写错了嗯。当然就通不过了。
------解决方案--------------------

 String hql ="from Model as c where = c.sid = '"+sid+"' ";


改成


 String hql ="from Model as c where c.sid = '"+sid+"' ";

------解决方案--------------------
HTTP Status 500 - unexpected token: = near line 1, column 33 [from Model.as c where = c.sid = '5' ]; 


很明显啊 哥们  where后面多个等号哎
------解决方案--------------------
问题解决了,sql的问题。
  相关解决方案