Java EE Advanced (11) SSH Framework Integration FAQ Summary (ii) question 8
java.lang.ClassCastException: java.lang.String cannot is cast to Java.lang.Boolean
Solve
The mapping file for the Userdetail table in the database is as follows, and the XB field data type is a Boolean type, and the type defined in the Userdetail model class is a string type. This conclusion can be drawn. The data and type in the model class must be consistent with the field information in the Data table mapping file. You should be able to generate the Pojo class and the mapping file at the same time, but you did not set the settings when you were doing the project at that time, resulting in a later error.
question 9
Org.hibernate.PropertyAccessException:IllegalArgumentException occurred while calling setter of Cn.edu.ujn.model.User.orderses
Solve
The initial suspicion is that the data table mapping file is out of the question. The User.hbm.xml file has the following contents:
<set name= "orderses" inverse= "true" > <key> <column name= "userid"/> </key> <one-to-many class= "cn.edu.ujn.model.Orders"/> </set>
By referencing the textbook, it is known that the set set properties need to be mapped using the <Set.../> element, and the foreign key columns are mapped using the <key.../> element to ensure the association of persisted classes and collection properties. Hibernate maps the Set collection property when the mapping table name should be specified , that is, the code above should be changed to
<set name= "orderses" table= "Orders" inverse= "true" > <key> <!--Specify column names for foreign key fields-- < Column name= "userid"/> </key> <one-to-many class= "cn.edu.ujn.model.Orders"/> </set >
From the above definition, the variable orserses should be a set collection data type and should be defined as private set<string> orderses = new hashset< String> () and set its get, set method . Instead, it was previously defined as a string type, resulting in an error when the data type was found to be inconsistent at get.
With these changes, users can log on to the correct page when they enter the correct user name and password.
question ten
clearly in The JS method is called within the JSP file, but it has no effect at all.
Solve
After debugging directly in the JS file to execute alert ("test"), pop-up windows, and Window.alert ("test"), but there is no pop-up window, after a search on the internet, also did not find a reasonable explanation. Change the pop-up window to alert (), and then the problem is resolved.
problem one by one
The statement exists in the JSP page: < S:property Value="#request. Msg"/>, where request is the variable defined in the action.
map request = (map) Actioncontext. GetContext (). Get ("request");
request.put ("Request", "Old password error, please re-enter");
However, when your old password is lost, the error message is always not displayed.
Solve
Again control video found that the original is the code of the wrong, O (︶^︶) o Alas, I do not know why Ah! In fact, before you look at the code is wrong. The correct code is as follows:
Map request = (map) actioncontext.getcontext (). Get ("request"); Request.put ("msg", "Old password error, please re-enter");
problem
When you set up a paging operation, there is always a phenomenon that does not display correctly. As shown in the following:
The JSP page code is as follows:
<s:iterator value= "#request. Catalogs" id= "Catalog" > <a href= "Browseflowerpagingaction.action? Catalogid=<s:property value= "#catalog. Catalogid"/>¤tpage=1 "target=" _self "><s:property value=" # Catalog.catalogname "/> </a> <br><br> </s:iterator>
Solve
The video again, and there is no place to find any flaws. And the address bar appears as
http://localhost:8088/flowergift/browseflowerpagingaction.action?catalogid=3¤tpage=1, but the console console displays Page.currentpage:2 . It made me very puzzled. Clearly set is displayed from the first page, why do not see the effect?
By careful observation of the code found that the original variable currentpage wrong write for the current p -age of the difference ah. The currentpage here is a member variable in the page class. I was too careless at the beginning, resulting in a special difficulty in the late inspection errors. O (︶^︶) o Alas, the pit of his own digging had to pit himself, and in the end had to pits himself.
<s:iterator value= "#request. Catalogs" id= "Catalog" > <a href= "Browseflowerpagingaction.action? Catalogid=<s:property value= "#catalog. Catalogid"/>currentpage=1 "target=" _self "><s:property value=" # Catalog.catalogname "/> </a> <br><br></s:iterator>
question
There was an error message when the order submission operation occurred:
Solve
The preliminary decision is caused by the inconsistency between the type of the variable in the model and the data type in the data table mapping file. This problem is similar to question 5 and question 9. After the lookup, it was found that the Flowerid in OrderItem is of type int, and unlike the Flowerid data type integer in flower, the problem is resolved after the change. For the difference between the integer and int data types, see note 4.
questions
when the order operation was submitted, it was found that there was no problem writing the Jkxyshsflower.orders table data, but the value of Flowerid in the Jkxyshsflower.orderitem table associated with the order was not written, and the problem Question 6 are quite similar, all of which involve cascading operational issues with tables. Question 6 has not been resolved so far. The mapping file for the Orders data table reads as follows:
Where the set collection is mapped, the configuration item is as shown. Note that the cascading attribute cascade= "All" is used. There is no problem with data writing in the video, but there is a situation in which you cannot write in your own practice.
Jkxyshsflower.orders table
Jkxyshsflower.orderitem table
Solve
After reviewing the program, it is found that it is still the problem of mapping file configuration errors, the best way is to use Hibernate reverse engineering function, automatically generated data table corresponding model class and mapping configuration file. Specific methods see the blog "Java EE Advanced (vii) using the SSH framework based on the data table model class ." This problem 6 is also resolved.
Jkxyshsflower.orders table
Jkxyshsflower.orderitem table
problem the
The following error message appears when the user is reported as missing:
Solve
The manageuser.jsp section code is as follows:
Where is the play, somehow, the program suddenly can. Restarting the service and clearing the cache in a timely manner is a common task.
American and American Pictures
Java EE Advanced (11) SSH Framework Integration FAQ Summary (ii)