我想自定义liferay dockbar view.jsp页面,并希望添加一个来自bean java文件的文本(Project Version)。但问题是我想初始化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目录中编译的。
答案 0 :(得分:0)
我想你想用:
<jsp:useBean id="someID" class="net.simplyfiIT.bean.UserManagementBean">
而不是
<%@page import="net.simplyfiIT.bean.UserManagementBean"%>
Bean应该放在类路径中。
(我自己是个菜鸟)