IDEA提示功能
package com.alan.test;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("hello world");
//ctrl+shift+space 自动返回声明的方法,会根据上下文进行判断。
String info = getInfo();
}
//command+shift+enter 自动对代码进行补全
public static String getInfo(){
return "hello world!";
}
public void test() {
//fori 之后按 command+shift+enter
for (int i = 0; i < 10; i++) {
System.out.println("hello");
}
}
//能对spring框架的类和xml进行智能感知
}
IDEA重构功能
- command+d 复制一行
- command+n 生成getter和setter方法等
- command+option+m 将选中的代码提取为方法
package com.alan.test;
public class Person {
String name;
int id;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
//快捷键command + n 生成getter setter方法等功能
//选中id 点击doRefactor 所有的相关项都一起修改了
@Override
public String toString() {
return "Person{" +
"name='" + name + '\'' +
", id=" + id +
'}';
}
public static void main(String[] args) {
Person user = new Person();
user.name = "smith";
user.id = 18;
System.out.println(user);
}
//command+option+m
public void test() {
print();
}
private void print() {
System.out.println("hello");
System.out.println("hello");
}
}
IDEA的编辑功能
- option+上 下键 选择不同区域的代码块
- option+shift+ 上下键盘 将选中的代码块上下移动
- option+左右键 按单词移动光标
- command+option+L 格式化代码
- command+p 提示构造方法
- command+E打开最近打开过的或编辑过的文件
IDEA的查找打开
- 按两次shift 可以查询任何内容
- command + o 查找类文件
新建一个web项目
-
web项目结构
image.png -
tomcat目录结构
image.png