Configuring JDeveloper 11g to use Struts 2

本文详细介绍了如何在 JDeveloper 11g 中手动配置 Web 项目以使用 Struts2 框架。从创建项目到添加必要的库文件,再到配置 struts.xml 文件和 web.xml 文件,最后实现简单的 Struts2 功能。

原文地址:http://203.208.33.132/search?q=cache:hSQNtuQxaqEJ:theblasfrompas.blogspot.com/2009/04/configuring-jdeveloper-11g-to-use.html+jdeveloper+struts2&cd=2&hl=zh-CN&ct=clnk&gl=cn&st_usg=ALhdy297q-NfZGbk_ZlYjK3n6mE45UIvdA

 

I was recently asked how to setup JDeveloper 11g web projects to use Struts 2 here is what I did to get this working. Keep in mind JDeveloper has design time support for Struts 1.x but not Struts 2 so this is a manual process.

1. Start Jdeveloper 11g
2. Select File | New | General | Applications | Generic Application
3. Name the application "Struts2Demo" and click next
4. Name the project "Demo" and press finish

Now at this point we want to add a simple JSP page to the project so
we end up with a web project , we will need to configure this to use
struts2 manually which we will do soon.

5. Right click on the project and select "New | Web Tier | JSP"
6. call the JSP "sayhello.jsp" and append "/pages" to the end of
the directory path so it creates the JSP in a sub directory called
"pages".

At this point you will need to download the Struts libraries. At a minimum,
you will need to put the following in your WEB-INF/lib directory of your
JDeveloper project:

* struts2 -core.jar (The framework itself)
* xwork.jar (Struts 2 is built on the XWork 2 framework)
* ognl.jar (Object Graph Notation Language is used throughout the framework)
* freemarker.jar (Freemarker is used to create UI tag templates in Struts 2)
* commons-logging.jar (Used to log to log4j or JDK logging)

Download struts2 from here. I am using 2.1.6 here.

http://struts.apache.org/download.cgi

7. Refresh the navigator to ensure your project shows the WEB-INF/lib folder
and the required struts2 libraries.
8. Double click on the project to invoke project properties dialog and
select "Libraries/Classpath"
9. Add the 5 jars files to the project and press OK. You could create
a single library and add the 5 JAR files to that library if you like.

Now we are ready to configure our project to use struts2 .

10. Open up the web.xml and add the following entries


<? xml version = '1.0' encoding = 'windows-1252' ?>
< web-app xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version = "2.5"
xmlns = "http://java.sun.com/xml/ns/javaee" >
< description > Empty web.xml file for Web Application </ description >
< filter >
< filter-name > struts2 </ filter-name >
< filter-class > org.apache.struts2 .dispatcher.FilterDispatcher </ filter-class >
</ filter >
< filter-mapping >
< filter-name > struts2 </ filter-name >
< url-pattern > /* </ url-pattern >
</ filter-mapping >
< session-config >
< session-timeout > 35 </ session-timeout >
</ session-config >
< mime-mapping >
< extension > html </ extension >
< mime-type > text/html </ mime-type >
</ mime-mapping >
< mime-mapping >
< extension > txt </ extension >
< mime-type > text/plain </ mime-type >
</ mime-mapping >
</ web-app >


11. Create a java class as follows


package demo . struts2 . action ;

import com . opensymphony . xwork2 . ActionSupport ;

public class ExampleAction extends ActionSupport
{
private String message ;

public String execute () throws Exception
{
this . message = "Hello from Struts 2" ;
return SUCCESS ;
}

public void setMessage ( String message )
{
this . message = message ;
}

public String getMessage ()
{
return message ;
}
}


12. Struts places its configuration in a struts.xml file. Create the file
at the root of your source folder for the project as follow. We’ll need
to add our new action to the struts.xml file.


<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">

< struts >
<!-- Configuration for the default package. -->
< package name = "default" extends = "struts-default" >
< action name = "ExampleAction" class = "demo.struts2 .action.ExampleAction" >
< result name = "success" > /pages/sayhello.jsp </ result >
</ action >
</ package >
</ struts >


13. Finally ensure the "sayhello.jsp" looks as follows


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType = "text/html;charset=windows-1252" %>
<%@ taglib uri = "/struts-tags" prefix = "s" %>
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=windows-1252" />
< title > sayhello</ title >
</ head >
< body >
< h2 >< s:property value = "message" /></ h2 >
</ body >
</ html >



Now we need to add the Struts2 tag library to our project.

14. Double click on the project to invoke the project properties and
select "JSP Tag Libraries"
15. Click the "Add" button
16. Select "Project" and then press the "New" button
17. Navigate to "public_html/WEB-INF/lib/struts2 -core.jar" and
press 'Open"
18. Verify it finds "Struts tage 2.2.3".
19. Press OK
20. Again double click on the project to invoke the project properties
and select "Java EE Application" and set the context root to "struts2demo"
and press Ok
21. Select File | save All
22. Select Build | Demo.jpr to ensure it compiles fine.
23. Navigate to the default domain directory LIB folder of the integrated server
and add the 5 JAR files we need for struts 2

eg: D:/jdev11g-boxer/jdeveloper /jdev/system11.1.1.0.31.52.05/DefaultDomain/lib

commons-logging-1.0.4.jar
freemarker-2.3.13.jar
ognl-2.6.11.jar
struts2 -core-2.1.6.jar
xwork-2.1.2.jar

Now JDeveloper doesn't provide support for running struts2 applications so you
will need to create some sort of index.jsp page which will redirect to our action
we created. Here we will just run the JSP and then alter the URL to invoke
your action so that the view page will render correctly.

23. Right click on "sayhello.jsp" and select "Run" to start the Integrated
WLS.

You will notice it displays nothing , that is due to the fact we have not
run the actual action which we do by altering the URL as follows

http://127.0.0.1:7101/struts2demo/ExampleAction.action

Note: I am not 100% sure why I need to add the struts2 JAR files to
the defualt domain LIB folder of my WLS server as I would expect it to find
those files in the WEB-INF/lib directory of the application which is how
struts1 works and I believe how struts2 should work. I even went back
to JDeveloper 10.1.3 and found that indeed it works there without
having to manilpulate it's classpath which proves the files in WEB-INF/lib
of the application is all that is needed.

 

配置注意事项:


1. jdeveloper现在还不支持直接运行strut2,所以需要手动配置

2. 写struts.xml时候, 在jdeveloper要建立一个普通的xml文件, 不可以使用new-struts-(struts-config.xml) 这样写进去是根据1的规范来定的, 所以加入新的tag会运行有问题.

3. 在添加jsp文件的时候, 同样要把文中提到的struts lib 2.2.3加进去, 这个才是strut2的lib, 否则也运行不了. 原因同1.


这个例子按照我下面配置注意的设置好以后可以运行


下载代码方式:https://pan.quark.cn/s/a4b39357ea24 HTML大屏展示模板是一种用于设计具有视觉冲击力且内容充实的巨型显示屏应用的设计方案,其应用范围广泛,涵盖了数据分析、监控以及决策支持等多个领域。这些模板通常整合了HTML、CSS、JavaScript等多种技术,尤其借助ECharts等数据可视化工具以达成复杂数据的图形化呈现。以下是对相关技术细节的深入说明: 1. **可视化**:数据可视化是将抽象的数据转化为直观的图像或图表的技术手段。这种技术有助于迅速识别数据中的模式、发展趋势和异常情况,使得非专业背景的人员也能轻松理解复杂的数据信息。在大屏展示场景中,可视化通常包含折线图、柱状图、饼图、热力图、地图等多种图表形式。 2. **大数据**:大数据指的是规模庞大、增长迅速、种类多样且数据密度较低的数据集合。在HTML大屏展示中,大数据的应用旨在支持实时或近乎实时的决策制定,例如监控销售业绩、交通流量、能源消耗等关键性能指标。 3. **HTML**:超文本标记语言(HTML)构成了网页内容的基础结构,用于界定页面的布局和元素。在大屏展示模板中,HTML负责构建页面组件,例如标题、段落、图像以及图表容器等。 4. **CSS**:层叠样式表(CSS)用于调控网页的视觉风格和布局结构。在大屏模板设计中,CSS扮演着核心角色,确保设计的响应性、适应性和美观度,包括设定颜色、字体、间距、动画效果等。 5. **ECharts**:ECharts是由百度研发的一款开源JavaScript数据可视化库,能够支持多种图表类型,如折线图、柱状图、散点图等,并提供了丰富的交互特性。在大屏展示中,ECharts能够助力生成动态且交互式的数据...
内容概要:本文针对拒绝服务(DoS)攻击威胁下孤岛微电网的运行安全问题,提出了一种兼顾功率精确均分与电压频率电能质量恢复的抗DoS混合动态事件触发二次控制策略,并通过Simulink平台完成了系统建模与仿真实现。该方法融合混合动态事件触发机制,在保证控制精度的同时有效降低通信网络负载,增强系统对DoS攻击的鲁棒性。通过设计分布式协同控制器,实现了在通信受限与恶意攻击耦合环境下的频率和电压协调调控,解决了传统控制方法在遭受攻击时可能出现的控制失效、状态发散或动态性能退化等问题。研究重点包括事件触发条件的设计、DoS攻击容忍边界的分析以及多智能体系统稳定性证明,最终确保微电网在异常工况下仍能维持稳定运行,提升其弹性与自治能力。; 适合人群:从事电力系统自动化、微电网控制、能源互联网安全、分布式控制理论及相关领域研究的研究生、高校科研人员及电力行业工程技术开发者,需具备现代控制理论基础、分布式控制知识以及Simulink/Matlab仿真能力; 使用场景及目标:①应用于面临网络安全威胁的微电网二次控制系统的安全设计;②为高比例可再生能源接入场景下的微电网提供具有弹性和抗干扰能力的协同控制解决方案;③支撑硕士或博士论文中关于事件触发控制、网络物理系统安全、多智能体协同控制等方向的研究与创新; 阅读建议:建议结合提供的Simulink仿真模型进行同步学习,重点关注混合动态事件触发机制的构造逻辑、Lyapunov-Krasovskii稳定性分析过程以及DoS攻击下系统性能退化与恢复的仿真对比实验,深入理解控制参数整定与攻击容忍阈值之间的关系,以便于复现、验证与进一步拓展研究。
代码转载自:https://pan.quark.cn/s/a4b39357ea24 ### Rufus 3.13 U盘制作工具详解 #### 一、简介 Rufus是一款性能卓越的U盘启动盘制作软件,能够协助用户迅速将U盘转变为可启动的安装载体,在Windows系统的部署与维护中具有广泛的应用。此次介绍的版本为Rufus 3.13,相较于先前的版本,该版本在稳定性和兼容性方面实现了明显的进步。 #### 二、特点与优势 1. **操作便捷**:Rufus的界面设计直观清晰,即便是计算机操作初学者也能够迅速掌握。 2. **跨平台支持**:兼容多种操作系统环境,涵盖了Windows 10、Windows 8/8.1、Windows 7等操作系统。 3. **快速高效**:能够在较短时间内完成U盘的格式处理及启动配置,显著降低了用户的时间成本。 4. **功能丰富**:不仅支持基础的U盘启动盘制作,还具备UEFI启动模式、ISO镜像文件写入等高级功能。 5. **个性化设置**:用户可根据实际需求调整U盘的文件系统类型、卷标等参数,以适应不同的使用场景。 #### 三、应用场景 1. **系统安装**:当计算机系统出现故障无法正常启动时,可借助Rufus制作的启动盘进行系统安装。 2. **数据管理**:通过启动盘中的工具执行硬盘数据的备份与还原操作。 3. **软件验证**:在不安装至主硬盘的情况下,利用启动盘对软件或系统的兼容性进行测试。 4. **网络问题诊断**:借助预置的网络检测工具对网络故障进行排查。 #### 四、操作流程 1. **获取并安装Rufus**:首先从官方网站或其他可信渠道获取Rufus 3.13安装文件,并遵循指引完成安装过程。 2....
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值