0

我想自定义 liferay 停靠栏 view.jsp 页面并想添加一个来自 bean java 文件的文本(项目版本)。但问题是我想初始化java类时出错。我对liferay很陌生,也不知道是否可以在liferay jsp页面中创建外部类对象。这是我的代码::

        <%@page import="net.simplyfiIT.bean.UserManagementBean"%>

        <%
        String version;     
        UserManagementBean bean=new UserManagementBean();
        version=bean.getVersion();
        %>

错误信息:

          Only a type can be imported. net.simplyfiIT.bean.UserManagementBean resolves to a package

An error occurred at line: 342 in the jsp file: /html/portlet/dockbar/view.jsp
 UserManagementBean cannot be resolved to a type
 339:               
 340:               <%
341:                String version;
342:                UserManagementBean bean=new UserManagementBean();
 343:               version=bean.getVersion();
 344:                   
  345: 


  Stacktrace:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:469)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)

注意: Bean 类编译在 tomcat 目录中。

4

1 回答 1

0

我想你想使用:

<jsp:useBean id="someID" class="net.simplyfiIT.bean.UserManagementBean">

代替

<%@page import="net.simplyfiIT.bean.UserManagementBean"%>

Bean 应该放在类路径中。

(我自己也是菜鸟)

于 2013-03-05T15:52:57.030 回答