Problems encountered in the development

1. The cross-domain problem
springboot configuration class plus
/ **
* Cross-Domain Support
* @param Registry
* /
@Override
public void addCorsMappings (CorsRegistry Registry) {
registry.addMapping ( "/ **")
.allowedOrigins ( "*")
.allowCredentials (to true)
.allowedMethods ( "GET", "POST", "DELETE", "PUT")
.maxAge (* 24-3600);

/ * xhrFields: {
withCredentials: to true
}, * /
}
! <- ================================= ======================================== ->
2. The front and rear end debugging across domains when, after the user logs in, the user can not obtain, but the machine is still normal.
User is stored in the session, the cross-domain request results caused by the inconsistency sessionId.
ajax plus
xhrFields: {
withCredentials: to true
},
<- ===================================! ===================================== ->
3. The user does not launch, switch to another user login Gets the menu information is still on a user information.
When users log out correctly, it will call session.invalidate () method, to destroy session, but the normal user is not logged,
the session will still remain in the session on a user's information.
GetAttributeNames method first call session when you log in, clear the information stored in a user session in.
The Enumeration <String> attributeNames session.getAttributeNames = ();
the while (attributeNames.hasMoreElements ()) {
ValueName attributeNames.nextElement = String ();
session.setAttribute (valueName, null);
}
! <- =========================== ======================================== ->
4.Hql parameter placeholder use

Use springdatajpa created query or hibernate under question subscript assignment,

Springdatajpa EntityManager created by native sql statement parameter markers in normal use digital footprint on it,
but use the hibernate session to create a query, the need for placeholder string.
JPA (java persistens api) way


// problematic jpa way
. Query Query = sessionFactory.openSession () the createQuery ( "from the WHERE u.name the User U = 0?")
Query.setParamter (0, "Line"); //? The latter figure is arbitrary, unnecessary starting from 0
get an exception message in the above manner:

  threw exception [Request processing failed; nested exception is org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 2] with root cause
  org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 2 

This is because Query is acquired hibernate packaged session, so we can not follow jpa way:

// method call is setParmter (string, string), not setParmter (int, String)
Query Query = sessionFactory.openSession (). The createQuery ( "from the WHERE u.name the User U =? 0")
query.setParamter ( "0", "line") ; //? The latter figure is arbitrary, apart from the unnecessary 0


In Hibernate 4 versions, for Hql a little change, if you are still under the previous way to write HQL Query query = sessionFactory.openSession (). CreateQuery ( "from User u where u.name =?") .SetParamter (0 , "line"); you'll get a warning.

得到的警告:
  [DEPRECATION] Encountered positional parameter near line 1, column 95. Positional parameter are considered deprecated; use named parameters or JPA-style positional parameters instead.

// prompted the above meaning, it does not advocate such a way that we apply a placeholder, but is recommended to use JPA or named parameter placeholders:

1: parameters are named

Query query = sessionFactory.openSession().createQuery("from User u where u.name =:name");
query.setParamter("name","line");


<-! ============================================ - >
5.Division undefined do with bigdicimal report when normal division by zero is by zero, this is an anomaly in addition to 0 of 0.


6. do remember the password when the user logs on, although there is no maximum time developed a cookie, but the cookie does not specify the location, there is no effect.


7. Use the time to export most of poi, the export volume of data is too large to export error, and later checked, the version of excel on the maximum number of lines of each sheet is limited, then that is
the maximum line to create a new sheet.

8. do with the imported poi time, because the user needs not the same, there are a number of data you want to import, import calculate how much more promising batch import


<-! Itext ->
return to the browser with itext repose time, itext there are several form field content can not always filled, thought it was a browser issue, and later with a few browser, not the browser found question, then thought, might be the font problem, then set up a Chinese character on it.

Guess you like

Origin www.cnblogs.com/lpp-xjj/p/11417510.html