当前位置: 代码迷 >> Java Web开发 >> 跪求大神,求解DWR注册验证用户,修改异常
  详细解决方案

跪求大神,求解DWR注册验证用户,修改异常

热度:288   发布时间:2016-04-10 23:35:44.0
跪求大神,求解DWR注册验证用户,修改错误

DAO层代码 //验证用户名 
public Iclouduser findReigsterName(String name){
Session session = this.getSession();
Iclouduser user = null;
try {
String hql = "from Iclouduser ic where ic.username=:username";
Query query = session.createQuery(hql);
query.setString("username", name);
user = (Iclouduser) query.uniqueResult();
} catch (Exception e) {
e.printStackTrace();
}
return user;
}
------------------
UserReigsterDwr //验证用户方法
public class UserReigsterDwr {
private IclouduserDAO userDao;
//验证用户
public boolean checkReigster(String name) {
boolean bool = false;
try {
Iclouduser user = userDao.findReigsterName(name);
System.out.println("打印++++++++"+user.getUsername());
if (null != user) {
System.out.println("有对象");
bool = true;
} else {
System.out.println("没对象");
bool = false;
}
} catch (Exception e) {
e.printStackTrace();
}
return bool;
}
-----------------------------
jsp页面代码
<script type="text/javascript" src="dwr/engine.js"></script>
<script type="text/javascript" src="dwr/util.js"></script>
<script type="text/javascript" src="dwr/interface/checkReigsterName.js"></script>

function checks(){
var usernawc = document.getElementById("username").value;
checkReigsterName.checkReigster(usernawc,no);
}
function no(boolean){
if(boolean){
alert("已注册");
}else{
alert("没注册")
}
}

<th><span class="must">*</span>用户名:<input type="button" value="测试" onclick="checks()"/></th><td><input class="input_name" type="text" name="icloudUser.username" id="username"
onblur="checkNull(this)" onfocus="checkFocus(this)" maxlength="20"  size="30"/>
--------------------------------
DWR.XML代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC
    "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
    "http://getahead.org/dwr/dwr20.dtd">
<dwr>
    <allow>
<create creator="new" javascript="checkReigsterName">
<param name="class" value="com.iCloud.dwr.UserReigsterDwr"></param>
<!-- <include method="checkReigsterName" />-->
</create>
</allow>
</dwr>
--------------------------
myeclipse里报的错误:
DEBUG - --Object created,  not stored. id=0
java.lang.NullPointerException
at com.iCloud.dwr.UserReigsterDwr.checkReigster(UserReigsterDwr.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34)
at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:431)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:283)
at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
DEBUG - out(375548): //#DWR-INSERT
DEBUG - out(375548): //#DWR-REPLY
  相关解决方案