public class Infomation {.../*** 获取当前JAVA的版本号* @return 当前JAVA的版本号*/public static String getJavaRuntimeVersion(){return System.getProperty("java.runtime.version");}}我在JSP里面这样写的:JAVA版本[getJavaRuntimeVersion()]:<br><jsp:getProperty name="info" property="javaRuntimeVersion" ></jsp:getProperty>但系统提示找不到属性。是怎么回事?补充一下:系统提示org.apache.jasper.JasperException: Cannot find any information on property 'javaRuntimeVersion' in a bean of type 'com.guiren100.Infomation'[com.guiren100]是我的一个包。 再补充一下:jsp里面写的“JAVA版本[getJavaRuntimeVersion()]:<br>”这一句是明文,“ <jsp:getProperty name="info" property="javaRuntimeVersion" ></jsp:getProperty>”这一句是用的bean。“getJavaRuntimeVersion()”命名不是符合bean里的jsp:getProperty调用方法的格式吗?请细心人看清楚再回答。
2 回答
红颜莎娜
TA贡献1842条经验 获得超13个赞
jsp中使用java的静态属性有两种情况:
1、如果是object的话,应该使用jsp:bean来引用。只有配合使用jsp:getProperty才有用。
2、如果是静态的函数的话,在jsp页面引入该类:
<%@ page language="java" import="java.util.*,com.rh.entity.*" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
import="java.util.*,com.rh.entity.*"
加上这句,可以在jsp中用了
<%=Infomation.getJavaRuntimeVersion() %>
添加回答
举报
0/150
提交
取消
