@GetMapping 和 @RequestMapping 的区别
虽然说@GetMapping 是下面注解的组合体,但是下面的注解不需要@RequestParam 来获取参数,可直接用参数名称获取。@GetMapping 可以通过 @RequestParam 来获取参数。个人做的一个简单的测试,没有深入去看源码。

package csdn;
import java.util.Scanner;
public class Commun {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
UnitPrice phone = new phone();
UnitPrice tv = new phone();
UnitPrice computre = new phone();
// 输入空格分隔
String[] strings = scanner.next().split(" ");
int[] ints = new int[]{Integer.valueOf(strings[0]),Integer.valueOf(strings[1]),Integer.valueOf(strings[2])};
System.out.println("总金额为:"+ints[0]*phone.unitprice()+ints[1]*tv.unitprice()+ ints[2]* computre.unitprice());
}
}
class phone implements UnitPrice{
@Override
public double unitprice() {
return 1.00;
}
}
class tv implements UnitPrice{
@Override
public double unitprice() {
return 2.00;
}
}
class computre implements UnitPrice{
@Override
public double unitprice() {
return 3.00;
}
}