struts2+hibernate+spring的经典整合
来源:互联网 发布:网上加盟淘宝店可靠吗 编辑:程序博客网 时间:2024/05/01 14:18
前面我们说了Struts2+hibernate+spring的基础整合,现在我就简单的介绍一下我现拥有的经典整合。
废话就不说了,进入主题。有什么不懂的就给我留言咨询。
所需jar包如下:
struts配置文件:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<!--配置struts2应用于开发模式-->
<constant name="struts.devMode" value="true"/>
<!-- 配置Convention插件自动重加载映射 -->
<constant name="struts.convention.classes.reload" value="true"/>
<!-- 是否从包中搜索Action -->
<constant name="struts.convention.action.disableJarScanning" value="true" />
<!-- Convention插件以该常量指定包作为根包 -->
<constant name="struts.convention.action.package" value="com.fun.actions" />
<!-- 设置Convention插件定位视图资源的根路径。默认值为/WEB-INF/content -->
<constant name="struts.convention.result.path" value="/WEB-INF/content" />
<!-- 如果是为false则可以将试图放置Action对应的目录下,无需放入WEB-INF/content -->
<constant name="struts.convention.result.flatLayout" value="true" /><!--
<package name="default" extends="strurts-dufault" namespace="/">
<action name="ggg" class="com.fun.actions.LoginAction" method="abc">
<result>ggg</result>
</action>
</package>
--></struts>
web.xml配置文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>Struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>Struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
</web-app>
spring配置文件:0
测试类:
LoginAction.java
package com.fun.actions;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport {
private String str;
@Actions({
@Action(value="login1",params={"str","这是已经注 入的了!"}),
@Action(value="login2")
})
public String login(){
return "str";
}
@Action(value="ggg")
public String abc(){
System.out.println("来了");
return "abc";
}
public String getStr() {
return str;
}
public void setStr(String str) {
this.str = str;
}
}
测试页面 test.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
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 'ggg-str.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>
<h1>Hello</h1>
</body>
</html>
- struts2+hibernate+spring的经典整合
- struts2 spring hibernate的整合
- struts2+hibernate+spring的整合
- Struts2+Spring+Hibernate的整合
- Struts2+Spring+Hibernate的整合
- struts2+hibernate+spring整合
- struts2 spring hibernate 整合
- Spring struts2 hibernate 整合
- struts2+spring+hibernate整合
- struts2+spring+hibernate整合
- struts2+spring+hibernate整合
- Spring、Struts2、Hibernate整合
- Spring + Hibernate + Struts2整合
- struts2+spring+hibernate整合
- struts2+spring+hibernate整合
- Struts2+Hibernate+Spring整合
- Spring Struts2 Hibernate整合
- 整合struts2+spring+hibernate
- 金属材质的参数
- MFC中添加热键
- SQL Server 2005 'Text,nText,image'数据类型被varchar(max)、nvarchar(max) 和 varbinary(max) 替代(转载自http://www.cnblogs.com/sunrack/articles
- 保护眼睛(眼睛好舒服)
- 今天忙了些啥
- struts2+hibernate+spring的经典整合
- 如何秒杀
- 云计算的关键特点及挑战
- 网页中调用QQ“联系我们”
- 如何获取Access中所有表
- notes of c++ primer (1)
- QT编程中如何给按钮等控件加载图标以及QT编程中使用中文的问题
- DB2客户端配置
- Is it time to start using high-level synthesis?