没有合适的资源?快使用搜索试试~ 我知道了~
首页struts2-portlet学习手册
资源详情
资源评论
资源推荐

Apache Struts 2 Documentation
Struts 2 Portlet Tutorial
Edit Page Browse Space Add Page Add News
Added by Nils-Helge Garli, last edited by Philip Luppens on Mar 12, 2008 (view change) SHOW COMMENT
Struts 2 Portlet Tutorial - Creating a simple Bookmark Portlet
Preparations
In this tutorial we will use eclipse as our IDE. If you do not have Eclipse, you can download it from http://www.eclipse.org .
The project itself will be set up using Maven 2. Maven 2 is available from http://maven.apache.org
.
If you have not used the maven-eclipse-plugin before, you need to set up the Eclipse workspace with a variable that points to the Maven 2 repository. To do this, type
mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo
Creating the project
We'll use Maven 2 with the Struts 2 Portlet Archetype to create a skeleton project for our portlet application. From the command line, issue the command:
mvn archetype:create -DarchetypeGroupId=org.apache.struts -DarchetypeArtifactId=struts2-archetype-portlet -DarchetypeVersion=2.1.1-SNAPSHOT -DartifactId=bookm
a
-DgroupId=com.mycompany -DremoteRepositories=http://people.apache.org/repo/m2-snapshot-repository
This will set up the maven 2 structure for us and also set up the basic configuration needed to create a Struts 2 portlet. The archetype creates a sample HelloWorld portlet that shows off
some of the basic principles of Struts 2 portlet programming. To test the set up, type
mvn jetty:run -P pluto-embedded
in a command prompt. Open a browser and point your browser to http://localhost:8080/bookmark
-portlet/pluto/index.jsp and play around.
Looking at the basics
To see how the basic HelloWorld example works, let's look at some of the configuration files, starting with the JSR168 portlet descriptor
src/main/webapp/WEB-INF/portlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<portlet-app
version="1.0"
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
id="bookmark-portlet">
<portlet id="HelloPortlet">
<description xml:lang="EN">Simple hello world portlet</description>
<portlet-name>HelloPortlet</portlet-name>
<display-name xml:lang="EN">bookmark-portlet</display-name>
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>
<!-- The namespace for the actions configured for view mode -->
<init-param>
<name>viewNamespace</name>
<value>/view</value>
</init-param>
<!-- The default action to invoke in view mode. -->
<init-param>
<name>defaultViewAction</name>
<value>index</value>
</init-param>
<!-- The namespace for the actions configured for edit mode -->
<init-param>
<name>editNamespace</name>
<value>/edit</value>
</init-param>
<!-- The default action to invoke in edit mode. -->
<init-param>
<name>defaultEditAction</name>
<value>index!input</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
<portlet-mode>edit</portlet-mode>
</supports>
<supported-locale>en</supported-locale>
<portlet-info>
<title>HelloPortlet</title>
Apache Struts 2 Documentation
> Home > Guides > Plugin Developers Guide > Portlet Plugin > Struts 2 Portlet Tutorial
Google Search
Work in progress
Using version 2.1.1-SNAPSHOT of the portlet plugin
Note that this tutorial assumes that you're familiar with basic Struts 2 web application programming.
If you have not used Struts 2 before, please check out some of the other Struts 2 tutorials first.















安全验证
文档复制为VIP权益,开通VIP直接复制

评论1