Struts2--jdk1.4--weblogic8.x
由于Struts2架构不能直接在jdk1.4的weblogic8.x下直接发布,所以,经常遇见一些朋友问“Struts2框架的系统在weblogic8.x如何发布”,我也不想再详细说struts2架构的搭建了,只就把工作笔记中的一部分拿出来贴在这里。
1、获得struts2开发包struts-2.0.11-all.zip;
2、解压缩后,在“struts-2.0.11\j4”目录下创建批处理文件“translate_others”,内容如下:
java -jar retrotranslator-transformer-1.2.2.jar -advanced -srcjar ../lib/struts2-sitemesh-plugin-2.0.11.jar -destjar struts2-sitemesh-plugin-j4-2.0.11.jar
java -jar retrotranslator-transformer-1.2.2.jar -advanced -srcjar ../lib/struts2-spring-plugin-2.0.11.jar -destjar struts2-spring-plugin-j4-2.0.11.jar
java -jar retrotranslator-transformer-1.2.2.jar -advanced -srcjar ../lib/commons-logging-1.0.4.jar -destjar commons-logging-j4-1.0.4.jar
3、执行translate_others.cmd,并拷贝该目录下的8个文件到eclipse的workspace下project目录的lib下,做为项目加载类文件,文件名称如下:
backport-util-concurrent-3.0.jar
retrotranslator-runtime-1.2.2.jar
retrotranslator-transformer-1.2.2.jar
struts2-core-j4-2.0.11.jar
xwork-j4-2.0.4.jar
struts2-sitemesh-plugin-j4-2.0.11.jar
struts2-spring-plugin-j4-2.0.11.jar
commons-logging-j4-1.0.4.jar
4、从“struts-2.0.11\lib”目录中拷贝2个类文件到project目录的lib下,文件名如下:
ognl-2.6.11.jar
freemarker-2.3.8.jar
5、将spring组件包拷贝到project目录的lib下,文件名称如下:
spring.jar
6、在project的src目录下创建struts.xml配置文件,内容如下:
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-default.xml"/>
<package name="demo" extends="struts-default">
<action name="HelloWorld" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean id="HelloWorldAction" scope="prototype">
</bean>
</beans>
9、在WebRoot\WEB-INF目录下创建web.xml,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<display-name>Demo系统</display-name>
<!-- Listener contextConfigLocation -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext.xml
</param-value>
</context-param>
<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>
<!-- The Welcome File List -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
10、在WebRoot目录下创建sayhello.jsp,用以调用action,内容如下:
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Say Hello 你好</title>
</head>
<body>
<h3>Say "Hello(你好)" to: </h3>
<s:form action="HelloWorld">
Name: <s:textfield name="name" />
<s:submit />
</s:form>
</body>
</html>
11、在WebRoot目录下创建index.jsp,用以获取返回信息,内容如下:
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
This is my JSP page. <br>
<h3><s:property value="name" /></h3>
</body>
</html>