Java 类 User.java
package com.test.bean;
public class User {
private Integer id;
private String name;
public User() {
super();
}
public User(Integer id, String name) {
super();
this.id = id;
this.name = name;
}
public Integer getId() {
return id;
}
public void setNId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
jsp 文件 index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.test.bean.User" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
User user = new User(1, "tom");
// 本机调试正常,服务器上运行异常
// int id = user.getId();
// 本机调试正常,服务器上运行正常
int id2 = user.getId().intValue();
// 本机调试正常,服务器上运行正常
Integer id3 = user.getId();
// 本机调试正常,服务器上运行正常
Integer id4 = new Integer(user.getId().intValue());
out.print("id2=" + id2 + "<br>");
out.print("id3=" + id3 + "<br>");
out.print("id4=" + id4 + "<br>");
%>
</body>
</html>