<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>ps:详细的操作自己多试试,lib下的类包已经是最简化的量了,具体什么意义大家去网上查好了。
恩已经按照楼上的改了,但之后出现的问题是 Error 500--Internal Server Error The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location] at org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60) at org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:52) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:49) at jsp_servlet.__index._jspService(__index.java:151) at weblogic.servlet.jsp.JspBase.service(JspBase.java:33) at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:526) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7051) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
http://atemper.blog.sohu.com/108981156.html
===================================================================================内容如下:
===================================================================================
由于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
freeer-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" class="HelloWorldAction">
<result>index.jsp</result>
</action>
</package>
</struts>
7、在project的src目录下创建 struts.properties,内容如下:
struts.locale=zh_CN
#指定Web应用的默认编码集。该属性对于处理中文请求参数非常有用,对于获取中文请求参数值,应该将该属性值设置为GBK或者GB2312
struts.il8n.encoding=GBK
# 开发调试模式开关(调试用)
struts.devMode=true
#每次HTTP请求到达时,系统都重新加载资源文件(调试用)
struts.il8.reload=true
# 使用spring来创建创建对象(如Action等)
struts.objectFactory=spring
8、在project的 src目录下创建applicationContext.xml,内容如下:
<?xml version="1.0" 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" class="cn.yxc.company.actions.HelloWorld" 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>ps:详细的操作自己多试试,lib下的类包已经是最简化的量了,具体什么意义大家去网上查好了。
Error 500--Internal Server Error
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
at org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
at org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:52)
at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:49)
at jsp_servlet.__index._jspService(__index.java:151)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:526)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7051)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
<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>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/struts/*</url-pattern>
</filter-mapping>