java编译成.class 有两种方式
使用javac,默认使用的release方式。
release模式下对于函数参数会改变
public class Test{
private static void sayHello(){
System.out.println("Hello world");
}
public static void main(String[] args){
sayHello();
}
}
使用不同的编译方法编译类文件,可以发现,使用debug方法编译产生的Test.class(如下)和用release方法编译(如下)出来的参数名上有所区别。
debug方法:
public class Test
{
private static void sayHello()
{
System.out.println("Hello world");
}
public static void main(String[] args) {
sayHello();
}
}
release方法:
public class Test
{
private static void sayHello()
{
System.out.println("Hello world");
}
public static void main(String[] paramArrayOfString) {
sayHello();
}
}
这也可以
解释为什么在spring MVC 中controller的注解初始化参数建议指定名称:
@RequestMapping(/test/{str})
public String test(@PathVariable String str){
System.out.println(str);
return null;
}
项目部署如果使用的是release版本,这样str(参数中的str发生变化)而非RequestMapping中的{str}这样就对应不起来了。。。然而dubug模式下函数参数不会发生变化。。