2013年9月15日星期日

Help null pointer problem

This small example is to use spring MVC + mybatis do
login page can go jump to enter the password click submit add.do
can get as
results to the next method of finding out the data in the figure NULL


paste the following configuration file in the sql


pursuing big God pointing a brother grateful

------ Solution ------------------------------------ --------
I think certainly where is a small problem
landlord tuning to be patient now , one step at a time
find the location of a null pointer exception
refuel
------ For reference only ---------------------------------------
someone did , Jiqiu
------ For reference only --------------------------------------- < br> sql you need two parameters username, password. And your method only one parameter ( do not know what is behind the business ? )
If there is no empty database query to the username illustrate the records , there may be data does not exist Yeah !
------ For reference only -------------------------------------- -


I do not preach what the past is an entity ~ ~ ~
------ For reference only ---------------------- -----------------

is this method error, I suspect that the sql problems, never used mybatis

------ For reference only ---------------------------------- -----

1. root mybatis okay, the front page of the data in the struts are not, how a relationship with mybatis
In addition, if an object is passed in the form of words
1.struts member variable in the object name Obj, has set get methods ( another non-standard naming may take less than the value of the struts cause problems with naming hump )
2. Properties page written Obj.xxx corresponding input box
3. object property name to see if there is no mistake
If you guarantee that you did something wrong , you should not mistake
------ For reference only -------------------- -------------------
you put the whole code Tieshanglai
------ For reference only --------- ------------------------------


useless struts, just springmvc write
------ For reference only -------------------------- -------------
learn JAVA sure to locate the abnormal location ! !
null pointer is the most common but also the best handling exceptions.

------ For reference only ---------------------------------- -----
breakpoint debugging
played the console to get the database sql statement execute it and see
look at your code is not a problem , the best overall code stickers out
------ For reference only ----------------- ----------------------
entity class

mapper:

mapper.xml

serviceImp

controller

------ For reference only ----- ----------------------------------
you see the console print out the sql statement is what ? ? ?
------ For reference only -------------------------------------- -


how print ... never used mybatis,
------ For reference only ---------------------- -----------------
breakpoint debugging , the console will sql statement
------ For reference only ------- --------------------------------
break point for program tracing . Look in the end is which object is empty. . Very easy to solve.
------ For reference only ------------------------------------ ---
If you do not add this , myBatis I am also a long time useless, should be able to see the sql statement

01.<?xml version="1.0" encoding="UTF-8" ?>  
02.<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">  
03.  
04.<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">  
05.  
06.    <!-- Console output -->  
07.  
08.    <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">  
09.        <layout class="org.apache.log4j.PatternLayout">  
10.            <param name="ConversionPattern" value="%-5p %d{MM-dd HH:mm:ss} %m  (%F:%L) \n" />  
11.        </layout>  
12.    </appender>  
13.  
14.    <category name="java.sql">  
15.        <priority value="debug" />  
16.    </category>  
17.    <category name="com.ibatis">  
18.        <priority value="debug" />  
19.    </category>  
20.    <root>  
21.        <priority value="error" />  
22.        <appender-ref ref="STDOUT" />  
23.    </root>  
24.  
25.</log4j:configuration>  
log4j.xml 添加 

------ For reference only ----------------------------------- ----
seems no execute sql., ...
------ For reference only --------------------- ------------------

sql statement before the sentence is being given no output , it may not perform
---- - For reference only ---------------------------------------
you have Definition mapped SQL statement that ah. If you do not define how to know where to find them MyBatis language
------ For reference only ----------------------- ----------------


dying, or fix, the mapping statement some
------ For reference only ----------------------------------- ----
account there anything? Before calling sq break out
------ For reference only -------------------------------- -------
and look Huashan arrows
------ For reference only ---------------------------------- -----

can print out some I see in the console

------ For reference only ---------------------------------- -----
finally good Thank you for your help,
------ For reference only ---------------------------------------





hey finally get a good few hours Thank you
------ For reference only ------------------ ---------------------
Where are you wrong ? ? ? ?

没有评论:

发表评论