- 浏览: 732736 次
- 性别:
- 来自: 重庆
文章分类
- 全部博客 (194)
- Webservice (6)
- ExtJs (2)
- Work Summary (4)
- CoreJava (51)
- Spring (10)
- EJB (5)
- struts1.x (3)
- C/C++ (5)
- DatabaseManager (19)
- Hibernate (5)
- Crytology (1)
- Web Server (5)
- Software Manager (5)
- WebUi (39)
- Web page (2)
- android (5)
- struts2 (12)
- Java 导出 Excel (1)
- Spring 与struts2 和Hibernate 4.0注解解决方安 (1)
- Dwr (1)
- maven3 (4)
- Windows (3)
- 表格头部信息不动使用Jquery 外部框架 (1)
- 软件行业动态 (1)
- mybatis (1)
- C# (3)
- MySQL (4)
最新评论
-
July01:
最近了解到一款StratoIO打印控件,功能如下:1、Html ...
LODOP插件开发 -
an52036:
u010980147 写道您的代码确实能生成条形码,但是打印出 ...
Java 条形码生成(一维条形码) -
di1984HIT:
学习了,很好~~
Ant 打包war 生成文件内容build.xml -
lhb319lhb:
如果 ajax(jquery)更新了 iframe 的 src ...
jquery 修改iframe src -
calosteward:
感谢楼主,除了一维条码,有没有相关二维码的资源呢?______ ...
Java 条形码生成(一维条形码)
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> <constant name="struts.devMode" value="false" /> <package name="usb" namespace="/add" extends="struts-default"> <action name="StuHell_*" class="stuHello" method="{1}"> <result name="success">/u.jsp</result> </action> </package> <!--package name="default" namespace="/" extends="struts-default"> <default-action-ref name="index" /> <global-results> <result name="error">/error.jsp</result> </global-results> <global-exception-mappings> <exception-mapping exception="java.lang.Exception" result="error"/> </global-exception-mappings> <action name="index"> <result type="redirectAction"> <param name="actionName">HelloWorld</param> <param name="namespace">/example</param> </result> </action> </package--> <!-- Add packages here --> </struts>
@author liuqing
@version 1.1
@datetime 2010-10-2
jndi 原理这里就不做介绍了
这里是调用tomcat jndi
首先配置 tomcat jndi
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --><!-- The contents of this file will be loaded for each web application --> <Context> <Resource name="jdbc/Hellooracle" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@192.168.0.xxx:1521:ORCL" username="xxx" password="xxx" maxActive="100" maxIdle="10" maxWait="-1"/> <!-- Default set of monitored resources --> <WatchedResource>WEB-INF/web.xml</WatchedResource> <!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> <!-- Uncomment this to enable Comet connection tacking (provides events on session expiration as well as webapp lifecycle) --> <!-- <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" /> --> </Context>
配置web.xml 文件
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>hibernate3.6test</display-name> <resource-ref> <description>Oracle Datasource example</description> <res-ref-name>jdbc/Hellooracle</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> <!-- - Location of the XML file that defines the root application context - Applied by ContextLoaderListener. --> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/applicationContext-*.xml </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <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>/*</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </web-app>
配置application-app.xml 文件
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>java:comp/env/jdbc/Hellooracle</value> </property> </bean> <!--bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="oracle.jdbc.OracleDriver" /> <property name="jdbcUrl" value="jdbc:oracle:thin:@192.168.0.108:1521:ORCL" /> <property name="user" value="bbsqyl" /> <property name="password" value="bbsqyl" /> </bean--> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource" /> </property> <property name="configLocation"> <value> classpath:hibernate.cfg.xml </value> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" > <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 配置事务拦截器 --> <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <!-- 事务拦截器bean需要依赖注入一个事务管理器 --> <property name="transactionManager" ref="transactionManager" /> <property name="transactionAttributes"> <!-- 下面定义事务传播属性--> <props> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <!-- 定义BeanNameAutoProxyCreator--> <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <!-- 指定对满足哪些bean name的bean自动生成业务代理 --> <property name="beanNames"> <!-- 下面是所有需要自动创建事务代理的bean--> <list> <value>*Service</value> </list> <!-- 此处可增加其他需要自动创建事务代理的bean--> </property> <!-- 下面定义BeanNameAutoProxyCreator所需的事务拦截器--> <property name="interceptorNames"> <list> <!-- 此处可增加其他新的Interceptor ,下面的拦截器仅用于生成 事务代理--> <value>transactionInterceptor</value> </list> </property> </bean> </beans>
添加action 文件
<?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.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <bean id="test" class="com.test.dao.TestSpringConnection"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="stuHello" class="com.test.action.StuHello" scope="session" > <property name="usb" value="struts2 successful" /> <property name="test" ref="test"></property> </bean> </beans>
发表评论
-
Spring mvc Token
2015-08-03 19:40 979request.getSession(false).s ... -
Spring dao 和Service 生成文件类
2012-02-13 09:23 2212package com.annotationtodaotose ... -
Spring 与struts2 和Hibernate 4.0 + Dwr 注解解决方安
2011-12-11 17:39 36421. web.xml 注册文件 < ... -
Spring jdbc 操作存储过程
2011-07-26 14:14 3854首先我们要用Spring 与 Jdbc 调用存储过程 ... -
SpringSecurity 2中文文档
2011-05-26 10:46 1069有不少同事在问spring security 2 有没有中文的 ... -
Spring3.0 Struts2 Hibernate 开发精华
2010-11-29 17:20 15591. 自动添加事务管理应用声明性事务 2. 直接引用hibe ... -
Spring 自动事务管理配置文件
2010-11-29 17:16 1803/* * To change this templat ... -
acegi web.xml
2010-10-24 23:14 1129<?xml version="1.0&q ... -
在web.xml 文件下添加 OpenEntityManagerInViewFilter
2010-06-17 13:35 3579错误原因 13:34:34,859 ERROR LazyIni ...
相关推荐
本书以使用Spring框架技术开发网络应用程序的实用技术为中心,全面、系统地...运用Spring+Hibernate开发校园管理系统,运用Spring+Struts+Hibernate开发企业门户网站,运用Spring+Java Swing开发企业进销存管理系统等。
5.2.1 使用JNDI数据源 5.2.2 使用数据源连接池 5.2.3 基于JDBC驱动的数据源 5.3 在Spring里使用JDBC 5.3.1 处理失控的JDBC代码 5.3.2 使用JDBC模板 5.3.3 使用Spring对JDBC的DAO支持类 5.4 在Spring里集成...
5.2.1 使用JNDI数据源 5.2.2 使用数据源连接池 5.2.3 基于JDBC驱动的数据源 5.3 在Spring里使用JDBC 5.3.1 处理失控的JDBC代码 5.3.2 使用JDBC模板 5.3.3 使用Spring对JDBC的DAO支持类 5.4 在Spring里集成...
5.2.1使用jndi数据源 5.2.2使用数据源连接池 5.2.3基于jdbc驱动的数据源 5.3在spring里使用jdbc 5.3.1处理失控的jdbc代码 5.3.2使用jdbc模板 5.3.3使用spring对jdbc的dao支持类 5.4在spring里集成hibernate ...
配置子报表数据源 14.7.5. 配置Exporter的参数 15. 集成其它Web框架 15.1. 简介 15.2. 通用配置 15.3. JavaServer Faces 15.3.1. DelegatingVariableResolver 15.3.2. FacesContextUtils 15.4. Struts 15.4.1. ...
用户提交表单时,一个配置好的ActionForm对象被创建,并被填入表单相应的数据,ActionServler根据Struts-config.xml文件配置好的设置决定是否需要表单验证,如果需要就调用ActionForm的 Validate()验证后选择将...
本书是《轻量级java ee企业应用实战》的姊妹篇,《轻量级java ee企业应用实战》主要介绍以spring+hibernate为基础的java ee应用;本书则主要介绍以ejb 3+jpa为基础的java ee应用。ejb 3、jpa规范都属于sun公司所...
325 18.4.2 配置数据库连接池 327 18.5 HQL简介 328 18.6 小结 330 第19章 权限管理系统(Struts+Spring+Hiberante+Ajax) 331 19.1 需求分析 331 19.2 系统总体流程设计 331 19.3 系统设计 332 19.4 系统总体解析 ...
105、spring工作机制及为什么要用? 24 106、HttpSession session = request.getSession() 24 107、getParameter与 getAttribute的区别? 24 108、以下哪一个不是赋值符号? 25 109、以下哪个不是Collection的子接口?...
105、spring工作机制及为什么要用? 24 106、HttpSession session = request.getSession() 24 107、getParameter与 getAttribute的区别? 24 108、以下哪一个不是赋值符号? 25 109、以下哪个不是Collection的子接口?...
5个目标文件,演示Address EJB的实现,创建一个EJB测试客户端,得到名字上下文,查询jndi名,通过强制转型得到Home接口,getInitialContext()函数返回一个经过初始化的上下文,用client的getHome()函数调用Home接口...
5个目标文件,演示Address EJB的实现,创建一个EJB测试客户端,得到名字上下文,查询jndi名,通过强制转型得到Home接口,getInitialContext()函数返回一个经过初始化的上下文,用client的getHome()函数调用Home接口...