ssh框架搭建问题 请问一下到目前为止搭建ssh开发环境,尽可能使用最新的各个版本,该如何整合,其环境该如何配置sshjava整合框架 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 导入的jar包Spring配置文件(ApplicationContext.xml)<?xml version="1.0" encoding="UTF-8"?><beans default-autowire="byName" xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://localhost:3306/ngbaojia"> </property> <property name="username" value="root"></property> <property name="password" value="charmingyb"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">true</prop> </props> </property> <property name="mappingResources"> <list> <value>com/ngbaojia/entity/Customerinfo.hbm.xml</value> <value>com/ngbaojia/entity/User.hbm.xml</value> <value>com/ngbaojia/entity/Offerprice.hbm.xml</value> <value>com/ngbaojia/entity/Enginner.hbm.xml</value> <value>com/ngbaojia/entity/Material.hbm.xml</value> <value>com/ngbaojia/entity/Materialcolumn.hbm.xml</value> <value>com/ngbaojia/entity/Enginnercolumn.hbm.xml</value> <value>com/ngbaojia/entity/Master.hbm.xml</value> <value>com/ngbaojia/entity/Deptmenu.hbm.xml</value> <value>com/ngbaojia/entity/Department.hbm.xml</value> <value>com/ngbaojia/entity/Menu.hbm.xml</value> </list> </property></bean> <bean id="UserDao" class="com.ngbaojia.dao.impl.UserDaoImpl"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="UserService" class="com.ngbaojia.service.impl.UserServiceImpl"> <property name="userDao" ref="UserDao"></property> </bean> <bean id="UserAction" class="com.ngbaojia.action.UserAction"> <property name="userService" ref="UserService"></property> </bean> </beans>struts 配置文件(struts.xml)<?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> <package name="ngbaojia" namespace="/" extends="struts-default"> <action name="getMasters" class="MasterAction" method="getMasters"> <result name="success">main.jsp</result> </action> <action name="login" class="UserAction" method="login"> <result name="success" >main.jsp</result> <result name="error">login.jsp</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"><context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext*.xml,classpath*: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> <!-- 编码配置 --> <filter> <filter-name>encodingfilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param> </filter> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list></web-app>hibernate的配置文件不用配置,hibernate已经托管给spring了。 1.建立web项目。2.引入struts2.X相关jar包,配置struts.xml和web.xml文件,启动服务,测试,确保struts2可以正常工作。3.在数据库中建相应的数据库和表,引入hibernate相关jar包,配置hibernate.cfg.xml文件,测试hibernate也正常工作。4.引入spring,配置web.xml及application.xml文件,将struts和hibernate的相关实例交给spring管理。总的来说就是这样一步一步来的,具体的还需要你自己摸索 最简单的方法:1)使用IDE 如myeclipse, 创建web工程, 然后右键选择工程, 在myeclipse> 菜单下, 有子菜单,如add structs capabilities 等, 你选择spring, hibernate, struts3个菜单 依次添加, 相应的jar包就有了。添加时,myeclipse会询问你要添加的版本, 你可以直接选择。2)使用Maven直接去appfuse, 使用maven archetype直接去创建一个空的SSH的工程。然后导入到IDE中, 支持Eclipse, IntelliJ Idea等。或者,你可以自己写个maven的pom.xml, 然后直接指定你要的版本,如: <!-- Spring Framework --> <dependency> < >org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> 请教 一个HttpClient的问题 websphere问题 用了struts,tomcat启动就出错 关于struts2 package之间跳转问题 ??JAVA实现自动搜索引擎并并进行自动化处理后导入数据库?? 下载文件时,选择“打开”,则提示错误 请问这个叫什么O? PO BO ?... 用Delphi7异步调用,出错啦!请各位大虾指教。 为什么在用struts做的jsp页面的输入框中的中文提交到后台后都变成了乱码,怎样解决? ejb1.1和2.0差别大嘛? struts2 怎么使用其他配置文件中的 拦截器 Hibernate执行存储过程报错:找不到存储过程 'dbo.DbInfo'。
<?xml version="1.0" encoding="UTF-8"?>
<beans default-autowire="byName" xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver">
</property>
<property name="url" value="jdbc:mysql://localhost:3306/ngbaojia">
</property>
<property name="username" value="root"></property>
<property name="password" value="charmingyb"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/ngbaojia/entity/Customerinfo.hbm.xml</value>
<value>com/ngbaojia/entity/User.hbm.xml</value>
<value>com/ngbaojia/entity/Offerprice.hbm.xml</value>
<value>com/ngbaojia/entity/Enginner.hbm.xml</value>
<value>com/ngbaojia/entity/Material.hbm.xml</value>
<value>com/ngbaojia/entity/Materialcolumn.hbm.xml</value>
<value>com/ngbaojia/entity/Enginnercolumn.hbm.xml</value>
<value>com/ngbaojia/entity/Master.hbm.xml</value>
<value>com/ngbaojia/entity/Deptmenu.hbm.xml</value>
<value>com/ngbaojia/entity/Department.hbm.xml</value>
<value>com/ngbaojia/entity/Menu.hbm.xml</value>
</list>
</property></bean>
<bean id="UserDao" class="com.ngbaojia.dao.impl.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="UserService" class="com.ngbaojia.service.impl.UserServiceImpl">
<property name="userDao" ref="UserDao"></property>
</bean>
<bean id="UserAction" class="com.ngbaojia.action.UserAction">
<property name="userService" ref="UserService"></property>
</bean>
</beans>
struts 配置文件(struts.xml)
<?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>
<package name="ngbaojia" namespace="/" extends="struts-default">
<action name="getMasters" class="MasterAction" method="getMasters">
<result name="success">main.jsp</result>
</action>
<action name="login" class="UserAction" method="login">
<result name="success" >main.jsp</result>
<result name="error">login.jsp</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">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml,classpath*: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> <!-- 编码配置 --> <filter> <filter-name>encodingfilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter> <welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>hibernate的配置文件不用配置,hibernate已经托管给spring了。
2.引入struts2.X相关jar包,配置struts.xml和web.xml文件,启动服务,测试,确保struts2可以正常工作。
3.在数据库中建相应的数据库和表,引入hibernate相关jar包,配置hibernate.cfg.xml文件,测试hibernate也正常工作。
4.引入spring,配置web.xml及application.xml文件,将struts和hibernate的相关实例交给spring管理。
总的来说就是这样一步一步来的,具体的还需要你自己摸索
1)使用IDE
如myeclipse, 创建web工程, 然后右键选择工程, 在myeclipse> 菜单下, 有子菜单,如add structs capabilities 等, 你选择spring, hibernate, struts3个菜单 依次添加, 相应的jar包就有了。添加时,myeclipse会询问你要添加的版本, 你可以直接选择。2)使用Maven直接去appfuse, 使用maven archetype直接去创建一个空的SSH的工程。
然后导入到IDE中, 支持Eclipse, IntelliJ Idea等。或者,你可以自己写个maven的pom.xml, 然后直接指定你要的版本,如: <!-- Spring Framework -->
<dependency>
< >org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>