67,513
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<!---->
<property name="connection.datasouce">java:comp/env/jdbc/mnet</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<property name="show_sql">true</property>
<mapping resource="com/m_netd/businessobjects/deyWorkTime.hbm.xml" />
<mapping resource="com/m_netd/businessobjects/employee.hbm.xml" />
<mapping resource="com/m_netd/businessobjects/funds.hbm.xml" />
<mapping resource="com/m_netd/businessobjects/monthPay.hbm.xml" />
<mapping
resource="com/m_netd/businessobjects/monthWorkTime.hbm.xml" />
<mapping resource="com/m_netd/businessobjects/news.hbm.xml" />
</session-factory>
</hibernate-configuration>
<?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>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<Resource
name="jdbc/m-net"
auth="Container"
type="javax.sql.DataSource"
password="root"
username="root"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mnettest"
maxActive="100"
maxIdle="30"
maxWait="5000"
/>
</Context>
<resource-ref>
<res-ref-name>jdbc/m-net</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
public List<NewsView> getNewsView(){
ArrayList<NewsView> newsList = new ArrayList<NewsView>();
List newsObject;
NewsView newsView;
News news;
try{
this.session = this.hibernateUtil.currentSession();
newsObject = this.session.find("from News");
ListIterator iterator = newsObject.listIterator();
while(iterator.hasNext()){
newsView = new NewsView();
news = (News)iterator.next();
newsView.setId(news.getId());
newsView.setDate(news.getDate());
newsView.setSubstance(news.getSubstance());
newsList.add(newsView);
}
}
catch (HibernateException e) {
System.out.println("error:" + e);
}
finally{
this.hibernateUtil.closeSession();
}
return newsList;
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<display-name>m-net</display-name>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>com.m_netd.framework.MnetActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>mnet-service-employee-class</param-name>
<param-value>com.m_netd.service.mnetService.MnetEmployeeService</param-value>
</init-param>
<init-param>
<param-name>mnet-service-funds-class</param-name>
<param-value>com.m_netd.service.mnetService.MnetFundsService</param-value>
</init-param>
<init-param>
<param-name>mnet-service-news-class</param-name>
<param-value>com.m_netd.service.mnetService.MnetNewsService</param-value>
</init-param>
<init-param>
<param-name>mnet-service-pay-class</param-name>
<param-value>com.m_netd.service.mnetService.MnetPayService</param-value>
</init-param>
<init-param>
<param-name>mnet-service-workTime-class</param-name>
<param-value>com.m_netd.service.mnetService.MnetWorkTimeService</param-value>
</init-param>
<!-- -->
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.mnet</url-pattern>
</servlet-mapping>
<filter>
<filter-name>SetCharacterEncoding</filter-name>
<filter-class>com.m_netd.framework.util.SetCharacterEncodingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SetCharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- The Usual Welcome File List -->
<welcome-file-list>
<welcome-file>security/logon.jsp</welcome-file>
</welcome-file-list>
<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/taglib/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/taglib/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/taglib/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/taglib/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/taglib/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/taglib/struts-logic.tld</taglib-location>
</taglib>
<!--
<Resource name="jdbc/m-net"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mnettest"
username="root"
password="root"
maxActive="5"
maxIdle="2"
maxWait="10000"/>
-->
</web-app>