你多久没有编程了(java),还记得这是哪的配置文件吗?java框架配置文件全解

一:spring的还有印象吗?


<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
                            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                            http://www.springframework.org/schema/context 
                            http://www.springframework.org/schema/context/spring-context-2.5.xsd
                            http://www.springframework.org/schema/tx 
                            http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
                            http://www.springframework.org/schema/aop 
                            http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
    
    <context:annotation-config />
    
    <context:component-scan base-package="要扫描的包">context:component-scan>
    
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="configLocation" value="classpath:hibernate.cfg.xml">property>
    bean>
    
    <bean id="txManage"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory">property>
    bean>
    
    <tx:annotation-driven transaction-manager="txManage" />
beans>`

二:hibernate的,是不是想到了什么。




<hibernate-configuration>

<session-factory>
    <property name="dialect">
        org.hibernate.dialect.MySQLDialect
    property>
    <property name="connection.url">
        jdbc:mysql://localhost:3306/dbname
    property>
    <property name="connection.username">账号(root)property>
    <property name="connection.password">密码(root)property>
    <property name="connection.driver_class">
        com.mysql.jdbc.Driver
    property>
    <property name="myeclipse.connection.profile">foodjxcproperty>
    <property name="show_sql">trueproperty>
    <property name="connection.autocommit">trueproperty>
    <mapping resource="*.hbm.xml(路径)" />
session-factory>
hibernate-configu>

三:struts的又勾起了你的回忆是不是



<struts>
    <package name=""  namespace="/"  extends="struts-default">
        <action name="" class="" method="">
            <result name="">/result>
        action>
    package>
struts>

四:dwr的 或许你一直看不上这落后的技术




<dwr>
    <allow>
            <create creator="spring" javascript="JUserCheck">
                <param name="beanName" value="userManager"/> 
                <param name="location" value="classpath:applicationContext.xml" />  
            create>

            <convert match="com.ltw.entity.Userinfo" converter="bean">convert>
    allow>

dwr>

五:dwr的web.xml配置


<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" 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>dwrdemodisplay-name>
  <welcome-file-list>
    <welcome-file>index.htmlwelcome-file>
    <welcome-file>index.htmwelcome-file>
    <welcome-file>index.jspwelcome-file>
    <welcome-file>default.htmlwelcome-file>
    <welcome-file>default.htmwelcome-file>
    <welcome-file>default.jspwelcome-file>
  welcome-file-list>
  <servlet>
    <servlet-name>dwrservlet-name>
    <servlet-class>org.directwebremoting.servlet.DwrServletservlet-class>
    <init-param>
      <param-name>debugparam-name>
      <param-value>trueparam-value>
    init-param>
    <init-param>
      <param-name>crossDomainSessionSecurityparam-name>
      <param-value>falseparam-value>
    init-param>
    <init-param>
      <param-name>allowScriptTagRemotingparam-name>
      <param-value>trueparam-value>
    init-param>
  servlet>
  <servlet-mapping>
    <servlet-name>dwrservlet-name>
    <url-pattern>/dwr/*url-pattern>
  servlet-mapping>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>
  listener>
  <context-param>
    <param-name>contextConfigLocationparam-name>
    <param-value>classpath:applicationContext.xmlparam-value>
  context-param>
web-app>

六:要附就附全吧,在web.xml中怎么配置struts2和监听spring


<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>foodjxc111display-name>
  <welcome-file-list>
    <welcome-file>index.htmlwelcome-file>
    <welcome-file>index.htmwelcome-file>
    <welcome-file>index.jspwelcome-file>
    <welcome-file>default.htmlwelcome-file>
    <welcome-file>default.htmwelcome-file>
    <welcome-file>default.jspwelcome-file>
  welcome-file-list>
  <filter>
    <filter-name>struts2filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilterfilter-class>
  filter>
  <filter-mapping>
    <filter-name>struts2filter-name>
    <url-pattern>/*url-pattern>
  filter-mapping>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>
  listener>
  <context-param>
    <param-name>contextConfigLocationparam-name>
    <param-value>classpath:applicationContext.xmlparam-value>
  context-param>
web-app>

七:连接池的配置还记得吗,你还记得context.xml文件吗。

"jdbc/login" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               username="sa" password="sa" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
               url="jdbc:sqlserver://localhost:1433;DatabaseName=sql"/>

八:就倒这了,是不是略感失望,是不是感觉这些配置文件,你一天不写十遍也有八遍,用得着这样吗?
要是这样我也只能说 我只是记记笔记而已!!!!

你可能感兴趣的:(java,框架,spring,ssh,java)