日期:2014-05-18  浏览次数:20613 次

寻大师: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&nbs