Home > Java > javaTutorial > Summary and sharing of small details in the javaWeb development process (2)

Summary and sharing of small details in the javaWeb development process (2)

黄舟
Release: 2017-03-17 11:10:56
Original
1642 people have browsed it

1. Method to convert json string into Java object and Java object array

  1. public static void main(String[] args) {  
      
        User_DAL userDal = new User_DAL();// 创建数据访问对象  
        ResponseResult<User> ret = userDal.getUserList("id < 50", 2, 10);// 查询ID小于50的用户,保存到分页类中  
        String json = JSON.toJSONString(ret, true); // 将对象转换成json字符串,true为格式化输出  
        System.out.println(json);  
          
        List<User> list = JSON.parseArray("{{name:123},{name:456}}", User.class);//将json字符串,转换成Java对象数组  
        for (int i = 0; i < list.size(); i++) {  
            System.out.println(list.get(i).getName());  
        }  
    }
    Copy after login


#2.jQueryAdd attributeDelete attribute

jQuery(
  $("#id").attr("
readonly
":"readonly");
 //添加readonly属性 & $("#ID").attr({ readonly: &#39;true&#39; });
  $("#id").removeAttr("readonly"); //去除readonly属性
);
Copy after login

3. When the form is submitted, there are objects and parameters.

Encapsulate the required objects first


#ajax passes data


Java background processing: fastJson converts json string into Java object



#4. When loading the js code of this code, the page always reports an error. This method cannot be found. There is no problem with the imported js. Then I wrap this code,

#No more errors will be reported when reloading the page.


##5. Text wrapping is often used as a test Bug mention, let’s write a public class to get rid of this painful thing!



##Place the following code in your CSS file That’s it:

.break-word { word-wrap: break-word; break-word: break-all; }
Copy after login

6. Automatically refresh the page to prevent session failure


7. How to use the INSERT INTO SELECT FROM statement with specific examples

If the fields of the two tables are the same, you can use it directly.

insert into table_a select * from table_b
如果两表字段不同,a表需要b中的某几个字段即可,则可以如下使用:
insert into table_a(field_a1,field_a2,field_a3) select field_b1,field_b2,field_b3) from table_b
以上语句前提条件是每个字段对应的字段类型相同或可以自动转换。
Copy after login

The above is the detailed content of Summary and sharing of small details in the javaWeb development process (2). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template