我在Spring MVC中有一个Web应用程序,并希望将此Web应用程序用作Liferay中的portlet。我创建了portlet控制器类,设置了web.xmlportlet.xmlliferay-portlet.xml
和其他文件。当我将portlet添加到Liferay时,我在浏览器控制台中收到错误:
Uncaught TypeError: Cannot read property 'liferay-form' of undefined
在
我将Liferay 6.2与Tomcat一起使用,没有注意到服务器日志文件中的任何错误。
我不知道该如何找到问题所在,也不知道什么是barebone。jsp
文件。
项目结构
SocialGraphUI-portlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:component-scan base-package="socialgraphui.controller" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
</bean>
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.json.GsonHttpMessageConverter" />
</mvc:message-converters>
</mvc:annotation-driven>
<bean class="org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
<bean class="org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<!-- Spring MVC Message Source -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="useCodeAsDefaultMessage" value="true"/>
<property name="basenames">
<list>
<value>content.socialGraph</value>
</list>
</property>
</bean>
</beans>
liferay显示屏。xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.2.0//EN" "http://www.liferay.com/dtd/liferay-display_6_2_0.dtd">
<display>
<category name="Social">
<category name="Other">
<portlet id="SocialGraphUI" />
</category>
</category>
</display>
liferay插件包。属性
name=serverTypeConfig
module-group-id=liferay
module-incremental-version=1
tags=
short-description=
change-log=
page-url=http://www.liferay.com
author=Liferay, Inc.
licenses=LGPL
portal-dependency-jars=jstl-api.jar,jstl-impl.jar
liferay-portlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_2_0.dtd">
<liferay-portlet-app>
<portlet>
<portlet-name>SocialGraphUI</portlet-name>
<instanceable>false</instanceable>
<requires-namespaced-parameters>false</requires-namespaced-parameters>
<header-portlet-css>/styles/layout-default.css</header-portlet-css>
<header-portlet-css>/styles/bootstrap_2.3.2.min.css</header-portlet-css>
<header-portlet-css>/styles/bootstrap.icon-large.css</header-portlet-css>
<header-portlet-css>/styles/datepicker.css</header-portlet-css>
<header-portlet-css>/styles/chosen.css</header-portlet-css>
<header-portlet-css>/styles/jquery.dataTables_1.10.3.css</header-portlet-css>
<header-portlet-css>/styles/bootstrapValidator_0.5.2.css</header-portlet-css>
<header-portlet-css>/styles/font-awesome.css</header-portlet-css>
<header-portlet-css>/styles/bootstrap-slider.css</header-portlet-css>
<header-portlet-css>/styles/main.css</header-portlet-css>
<header-portlet-javascript>/scripts/aui-min_2.0.0.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/jquery-1.9.1.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/bootstrap.min_2.3.2.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/bootstrapValidator_0.5.2.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/bootstrapValidator_cs_CZ.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/bootstrapValidator_en_US.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/jquery-ui-1.9.2.custom.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/jquery.layout.min-1.3.0.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/bootstrap-datepicker.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/bootstrap-slider.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/bootstrap-filestyle_1.1.2.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/chosen.jquery.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/chosen.proto.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/d3.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/graph.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/jquery.dataTables_1.10.3.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/underscore_1.7.0.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/set.layout.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/initialize.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/main.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/listeners_filter.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/listeners_details.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/listeners_modals.js</header-portlet-javascript>
<header-portlet-javascript>/scripts/validation.js</header-portlet-javascript>
</portlet>
<role-mapper>
<role-name>administrator</role-name>
<role-link>Administrator</role-link>
</role-mapper>
<role-mapper>
<role-name>guest</role-name>
<role-link>Guest</role-link>
</role-mapper>
<role-mapper>
<role-name>power-user</role-name>
<role-link>Power User</role-link>
</role-mapper>
<role-mapper>
<role-name>user</role-name>
<role-link>User</role-link>
</role-mapper>
</liferay-portlet-app>
portlet.xml
<?xml version='1.0' encoding='UTF-8' ?>
<portlet-app
xmlns='http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd'
version='2.0'>
<portlet>
<portlet-name>SocialGraphUI</portlet-name>
<portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
<init-param>
<name>contextConfigLocation</name>
<value>/WEB-INF/SocialGraphUI-portlet.xml</value>
</init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
</supports>
<supported-locale>en</supported-locale>
<supported-locale>cs</supported-locale>
<resource-bundle>content.socialGraph</resource-bundle>
</portlet>
</portlet-app>
网状物xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<!-- - Loads the root application context of this web app at startup, - by default from "/WEB-INF/applicationContext.xml". - Note that you need to fall back to Spring's ContextLoaderServlet for - J2EE servers that do not follow the Servlet 2.4 initialization order. - - Use WebApplicationContextUtils.getWebApplicationContext(servletContext)
- to access it anywhere in the web application, outside of the framework. - - The root context is the parent of all servlet-specific contexts. - This means that its beans are automatically available in these child contexts, - both for getBean(name) calls and (external) bean references. -->
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/portlet_2_0</taglib-uri>
<taglib-location>/WEB-INF/tld/liferay-portlet.tld</taglib-location>
</taglib>
</jsp-config>
<servlet>
<servlet-name>view-servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>view-servlet</servlet-name>
<url-pattern>/WEB-INF/servlet/view</url-pattern>
</servlet-mapping>
</web-app>
波姆。xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>socialgraphui</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>socialgraphui</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>4.1.0.RELEASE</spring.version>
<liferay.version>6.2.1</liferay.version>
<spring.data.version>1.6.1.RELEASE</spring.data.version>
</properties>
<dependencies>
<!-- LifeRay Dependency -->
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>${liferay.version}</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>uk.com.robust-it</groupId>
<artifactId>cloning</artifactId>
<version>1.7.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc-portlet</artifactId>
<version>${spring.version}</version>
<type>jar</type>
</dependency>
<!-- Spring Data JPA deps-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- END Spring Data JPA deps-->
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>2.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.3.5</version>
</dependency>
<!-- GOOGLE visualization -->
<dependency>
<groupId>com.google.visualization</groupId>
<artifactId>visualization-datasource</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
<version>1.0.3.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>${spring.data.version}</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
liferay portlet。tld
<?xml version="1.0"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.1</jsp-version>
<short-name>portlet</short-name>
<uri>http://java.sun.com/portlet</uri>
<tag>
<name>actionURL</name>
<tag-class>com.liferay.taglib.portlet.ActionURLTag</tag-class>
<tei-class>com.liferay.taglib.portlet.ActionURLTei</tei-class>
<body-content>JSP</body-content>
<attribute>
<name>copyCurrentRenderParameters</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>escapeXml</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>name</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>portletMode</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>secure</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>windowState</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>defineObjects</name>
<tag-class>com.liferay.taglib.portlet.DefineObjectsTag</tag-class>
<tei-class>com.liferay.taglib.portlet.DefineObjectsTei</tei-class>
<body-content>empty</body-content>
</tag>
<tag>
<name>namespace</name>
<tag-class>com.liferay.taglib.portlet.NamespaceTag</tag-class>
<body-content>JSP</body-content>
</tag>
<tag>
<name>param</name>
<tag-class>com.liferay.taglib.util.ParamTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>value</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>property</name>
<tag-class>com.liferay.taglib.util.PropertyTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>value</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>renderURL</name>
<tag-class>com.liferay.taglib.portlet.RenderURLTag</tag-class>
<tei-class>com.liferay.taglib.portlet.RenderURLTei</tei-class>
<body-content>JSP</body-content>
<attribute>
<name>copyCurrentRenderParameters</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>escapeXml</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>portletMode</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>secure</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>windowState</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>resourceURL</name>
<tag-class>com.liferay.taglib.portlet.ResourceURLTag</tag-class>
<tei-class>com.liferay.taglib.portlet.ResourceURLTei</tei-class>
<body-content>JSP</body-content>
<attribute>
<name>cacheability</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>escapeXml</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>secure</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
首先,我要检查portlet的所有必需依赖项,例如使用liferay taglib所需的依赖项:
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-taglib</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
另一方面,确保您的portlet解剖结构与官方网站上的普罗维登一模一样:
https://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/liferay-plugin-types-to-develop-with-maven https://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/anatomy-of-a-portl-4
例如你还没有提到liferay-display.xml如果这不能解决你的问题,提供你的portlet源(配置文件,和jsp文件抛出错误就足够了)
乍一看,您的web应用程序的javascript与Liferay的javascript似乎存在冲突。正如您所见,浏览器抱怨“Uncaught TypeError:无法读取undefined的属性”Liferay form“。这意味着,一旦在页面上添加portlet,它就会破坏Liferay的javascript。我会尝试从jsp中删除对所有js文件的引用,然后逐个添加它们,以查看哪个文件存在冲突,然后解决它们。
JFYI,liferay表单
可以从以下位置之一引用:https://github.com/liferay/liferay-portal/search?utf8=✓
问题内容: 如果这个问题已经回答,我深表歉意。我尝试搜索解决方案,但找不到适合我的代码的任何解决方案。我还是jQuery新手。 对于两个不同的页面,我有两种不同类型的粘滞菜单。这是两者的代码。 我的问题是,底部粘性菜单的代码不起作用,因为第二行代码会引发错误,提示“未捕获的TypeError:无法读取未定义的属性’top’”。实际上,除非将第二行以下的其他jQuery代码放在第二行之上,否则根本不
问题内容: 我收到此错误,它源自jquery框架。当我尝试在文档准备好加载选择列表时,出现此错误。我似乎找不到我为什么收到此错误的信息。 它适用于change事件,但是尝试手动执行功能时出现错误。 未捕获的TypeError:无法读取未定义的属性’toLowerCase’-> jquery-2.1.1.js:7300 这是代码 问题答案: 当您调用DOMReady时,的上下文将不是元素。 您可以通
问题内容: 我有一些JavaScript代码会给出此错误 码 这个错误是什么意思? 问题答案: 好像您的值之一,属性键为“值”是未定义的。在执行if语句之前测试,和是否已定义:
我刚开始使用D3,在我的演示脚本中出现了以下错误- firstd3.jsp:31未捕获的TypeError:无法读取未定义的属性“linear” 我的演示代码如下 是什么导致了这个错误?以及如何解决
我发现很多回答的问题与我的问题相似,但所有这些元素实际上都是“未定义的”。就我而言,它是存在的。 我的代码按预期工作。基本上,它将eventListener添加到作为锚的所有模式解除按钮中。关闭函数是找到最外层的modal div,并为其提供“hidden”类,该类将其显示设置为none。 它正确地关闭了模态,但在模态关闭后,该错误就会出现。 约会。js:61未捕获类型错误:无法读取未定义的属性“
我遵循这一点,使用DataTables插件启用多个表(在同一页上)。对于手动表,它可以工作,但对于动态创建的表,它显示以下错误: 未捕获的TypeError:无法读取未定义的属性“mData” 我的页面srcipt: 我的超文本标记语言第一个表: 第二张表: 知道怎么修吗? 注意:我也阅读了这个未回答的问题,相同的错误,但我的标准不同,因此它不是重复的。
我是JavaScript/jQuery的新手,我正在开发一个应用程序。尝试读取对象的属性时,我得到一个未捕获的TypeError。我的最终目标是让用户在一个文本框中输入一些内容,并基于该输入,创建一个对象,将该输入作为name属性。以下是我到目前为止的代码: 我在网站上搜索过类似的其他问题,但它们都是处理API或与我无关的问题。如果有任何帮助,我将不胜感激。
我正在使用react-router V4.1.1,当我试图使用Link组件时,我得到一个警告: 如果需要,我会附上我所有的组件。谢谢你的帮助。