Back-end & front-end fragmentary knowledge and attention problems

rear end

1. Spring comes MD5 encryption tools

import org.springframework.util.DigestUtils;

String md5Password = DigestUtils.md5DigestAsHex(password.getBytes());

2. The database field names do not contain is

For example, there is a database field is is_valid, then to code this variable to isValid. This happens if the variable is a Boolean type , then if the data is returned to the front end, the string is then json { "Valid":} to true , can be seen is unseen removed.

Look get method automatically generated, not get a prefix, because of the type of Boolean methods are beginning to get in is, and this will overwrite your name is in the prefix, so if your variable is a Boolean name to avoid It is beginning.

3. invalid comparison: org.springframework.web.bind.annotation.RequestMethod and java.lang.String

Others left the pit:

mybatis inside the sql statement, org.springframework.web.bind.annotation.RequestMethod is an enumeration class

<if test="requestMethod!=null and requestMethod!='' ">
    REQUEST_METHOD=#{requestMethod , jdbcType=VARCHAR, typeHandler=org.apache.ibatis.type.EnumTypeHandler},
</if>

Here's judgment: ! RequestMethod = '' lead to error, because how could you an enumeration class for string comparison?

 

 

front end

1. string turn number

<script>
$(document).ready(function(){
      var p = +$('p').text();
    $('div').text(p+1);
});
</script>
</head>
<body>
    <div></div>
    <p>1</p>
</body>
</html>

Output 2 instead of 11

2. JQuery warning, inefficient use of selectors

such as:

$('#resultData :checked');

Warns

Inefficient jQuery usage less... (Ctrl+F1)
Checks that jQuery selectors are used in an efficient way. It suggests to split descendant selectors which are prefaced with ID selector and warns about duplicated selectors which could be cached

It should read:

$('#resultData').find(':checked');

3. Comparison $.trim($(t[9]).val()) == "" may cause unexpected type coercion less...

For example: After removing the contents of the form to determine whether the space is empty

$.trim($(t[0]).val()) == ""

Warns

Should read:

$.trim($(t[0]).val()) === ""

Distinction 4. new Boolean (value) and Boolean (value) of

The former is the constructor function as a Boolean instance, is obtained a subject ; the latter as an ordinary function call, the return value of the function is obtained to false / to true .

5. Ajax request, the name of the array parameter passed more than a []

Use JQuery's $ .param (params, true) to solve

var myObject = {
  a: {
    one: 1, 
    two: 2, 
    three: 3
  }, 
  b: [1,2,3]
};
var recursiveEncoded = $.param(myObject);
var recursiveDecoded = decodeURIComponent($.param(myObject));

console.log(recursiveEncoded);
console.log(recursiveDecoded);

var shallowEncoded = $.param(myObject, true);
var shallowDecoded = decodeURIComponent(shallowEncoded);

console.log(shallowEncoded);
console.log(shallowDecoded);

 

Guess you like

Origin www.cnblogs.com/LUA123/p/10860712.html