您的当前位置:首页正文

easy UI mybatis springMvc 通过前台输入的时间查询数据库 Oracle

2023-11-11 来源:帮我找美食网

td>上传日期:</td> <td> <input class="easyui-datebox" id="createTimeQ" name="createTime" data-options="formatter:myformatter,parser:myparser" style="width:150px"/> </td> <td>至:</td> <td> <input class="easyui-datebox" id="updateTimeQ" name="updateTime" data-options="formatter:myformatter,parser:myparser" style="width:150px"/> </td>

js提交代码 我是用来查询列表信息的 用的是easyUI的datagrid控件 你可以用aiax的其他方式提交 post 或者get

$("#dosTable").datagrid(‘load‘, { createTime :$("#createTimeQ").datetimebox(‘getValue‘), updateTime :$("#updateTimeQ").datetimebox(‘getValue‘) });

 

后台层如下 获取时间

paramMap.put("createTime", request.getParameter("createTime")); paramMap.put("updateTime", request.getParameter("updateTime"));

 

此处用createTime 作为开始时间  用updateTime 作为结束时间 mbatis 的xml配置如下

<if test="createTime != null and createTime != ‘‘" >and CREATE_TIME > to_date(#{createTime,jdbcType=TIMESTAMP},‘yyyy-mm-dd hh24:mi:ss‘)</if><if test="updateTime != null and updateTime != ‘‘" >and CREATE_TIME< to_date(#{updateTime,jdbcType=TIMESTAMP},‘yyyy-mm-dd hh24:mi:ss‘)</if>

这样就可以通过前台时间查询后台了

 

easy UI mybatis springMvc 通过前台输入的时间查询数据库 Oracle

标签:dos   spring   inpu   信息   类型   数据   parser   for   jdbc   

小编还为您整理了以下内容,可能对您也有帮助:

怎么搭建springmvc和mybatis

SpringMVC+MyBatis+Freemarker 简单框架搭建(一)

一、开发环境:
Eclipse、Tomcat、SVN等请参见如下的帖子,很详细了。
http://www.iteye.com/topic/982182

svn和maven插件的安装:
1、先安装gef插件
地址:http://download.eclipse.org/tools/gef/updates/interim/
2、安装svn插件
地址:http://subclipse.tigris.org/update_1.6.x
3、maven插件
m2eclipse-core Update 地址: http://m2eclipse.sonatype.org/sites/m2e
m2eclipse-extras Update 地市: http://m2eclipse.sonatype.org/sites/m2e-extras
4、安装可能出现的问题
直接在线安装maven2 会出现依赖插件找不到的问题,无法安装。必须先安装gef 插件后才能安 装m2eclipse-core 插件,然而安装m2eclipse-extras 插件又依赖subclipse 插件。所以,三个插 件的正确的安装顺序是:gef插件 》subclipse插件 》m2eclipse插件

二、web.xml 和 applicationContext.xml 配置
1、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"
version="2.5">

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

<!-- Spring MVC 配置 -->
<servlet>
<servlet-name>springServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:contextConfigLocation-springService.xml</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

<!-- 事件* -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- shiro 权限控制的过滤器 -->

<!-- Spring 刷新Introspector防止内存泄露 -->
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>

<!-- session超时定义,单位为分钟 -->
<session-config>
<session-timeout>20</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<!-- 设置servlet编码开始 -->
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GB2312</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/</url-pattern>
</filter-mapping>
<!-- 设置servlet编码结束 -->

<display-name>Archetype Created Web Application</display-name>
</web-app>

<context-param>节点和<listener>节点是web项目启动时最先读取的两个节点,所以这两个节点里面所配置的内容是web项目启动时最先加载的部分。
<context-param>节点中配置的applicationContext.xml里面主要是数据库的配置信息,以及事务等等
<listener>节点配置的是web请求的*

2、applicationContext.xml 内容如下:

<?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" xmlns:context="http://www.springframework.org/schema/context"
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.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
">

<!-- 自动注解除Controller以外的Component -->
<context:component-scan base-package="com.weiluo.example">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>

<!-- 此配置可以让我们以${xxx}的形式来读取property.properties里面的信息 -->
<!-- <context:property-placeholder/> -->

<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>

<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driver}"></property>
<property name="url"
value="${jdbc.url}"></property>
<property name="username" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>

<!-- Connection Pooling Info -->
<property name="maxActive" value="${dbcp.maxActive}" />
<property name="maxIdle" value="${dbcp.maxIdle}" />
<property name="defaultAutoCommit" value="false" />
<!-- 连接Idle一个小时后超时 -->
<property name="timeBetweenEvictionRunsMillis" value="360000" />
<property name="minEvictableIdleTimeMillis" value="360000" />
</bean>

<!-- 配置SessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
p:dataSource-ref = "dataSource"
p:configLocation = "classpath:sqlMapConfig.xml" />

<!-- 采用spring与mybatis整合的第二种方法 -->
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>

<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
p:dataSource-ref = "dataSource" />

<!-- MapperScanner配置,自动搜索mapper里面的对象,并注入 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
p:basePackage = "com.weiluo.example.entity" />

<!-- 启动Spring注解事务 -->
<tx:annotation-driven/>

</beans>

3、web.xml中的<servlet>节点配置的是与请求处理相关的一些内容,主要是 url路由处理器,视图解析器,等等,如下:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">

<!-- url映射* -->
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="order" value="1" />
</bean>
<!-- 配置数据格式转换器 -->
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jsonHttpMessageConverter" />
</list>
</property>
</bean>
<bean id="jsonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
</bean>

<!-- 开启controller注解支持 -->
<!-- 注:如果base-package=cn.javass 则注解事务不起作用 TODO 读源码 -->
<context:component-scan base-package="com.weiluo.example.controller">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- 因为web-inf目录下面的静态资源文件是不能直接通过目录过去的,所以需要特殊声明-->
<mvc:resources location="/static/" mapping="/static/**" />

<!-- 视图解析器 -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="cache" value="true" />
<property name="prefix" value="" />
<property name="suffix" value=".html" />
<property name="exposeSpringMacroHelpers" value="true" />
<property name="exposeRequestAttributes" value="true" />
<property name="exposeSessionAttributes" value="true" />
<property name="requestContextAttribute" value="rc" />
<property name="contentType" value="text/html;charset=GB2312" />
<property name="order" value="0"/>
</bean>

<!-- 自定义的freemarker标签 -->
<bean id="blockDirective"
class="com.weiluo.example.freemarker.directive.BlockDirective" />
<bean id="extendsDirective"
class="com.weiluo.example.freemarker.directive.ExtendsDirective" />
<bean id="overrideDirective"
class="com.weiluo.example.freemarker.directive.OverrideDirective" />
<bean id="superDirective"
class="com.weiluo.example.freemarker.directive.SuperDirective" />

<!-- freemarker的配置项 -->
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/views/" />
<property name="freemarkerSettings">
<props>
<prop key="template_update_delay">5</prop>
<prop key="defaultEncoding">GB2312</prop>
<prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
<prop key="date_format">yyyy-MM-dd</prop>
<prop key="time_format">HH:mm:ss</prop>
<prop key="number_format">0.######</prop>
<prop key="whitespace_stripping">true</prop>
</props>
</property>
<property name="freemarkerVariables">
<map>
<entry key="extends" value-ref="extendsDirective"></entry>
<entry key="override" value-ref="overrideDirective"></entry>
<entry key="block" value-ref="blockDirective"></entry>
<entry key="super" value-ref="superDirective"></entry>
</map>
</property>
</bean>

</beans>

4、另外,一些常常变化的信息习惯于存放在application.properties文件里面,如:

#oracle version database setting
database=sqlserver
#jdbc.driver=oracle.jdbc.driver.OracleDriver
jdbc.driver=net.sourceforge.jtds.jdbc.Driver
#jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:jtds:sqlserver://127.0.0.1:1433;databaseName=SpringMyBatisExample
#jdbc.url=jdbc:mysql://localhost:3306/springmvcdemo
jdbc.username=sa
jdbc.password=sasa

#dbcp settings
dbcp.maxIdle=5
dbcp.maxActive=20

到这里,一个spring mvc的基本框架就已经搭建起来了。
后续再完成数据库mybatis的配置以及freemarker的配置。

怎么搭建springmvc和mybatis

SpringMVC+MyBatis+Freemarker 简单框架搭建(一)

一、开发环境:
Eclipse、Tomcat、SVN等请参见如下的帖子,很详细了。
http://www.iteye.com/topic/982182

svn和maven插件的安装:
1、先安装gef插件
地址:http://download.eclipse.org/tools/gef/updates/interim/
2、安装svn插件
地址:http://subclipse.tigris.org/update_1.6.x
3、maven插件
m2eclipse-core Update 地址: http://m2eclipse.sonatype.org/sites/m2e
m2eclipse-extras Update 地市: http://m2eclipse.sonatype.org/sites/m2e-extras
4、安装可能出现的问题
直接在线安装maven2 会出现依赖插件找不到的问题,无法安装。必须先安装gef 插件后才能安 装m2eclipse-core 插件,然而安装m2eclipse-extras 插件又依赖subclipse 插件。所以,三个插 件的正确的安装顺序是:gef插件 》subclipse插件 》m2eclipse插件

二、web.xml 和 applicationContext.xml 配置
1、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"
version="2.5">

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

<!-- Spring MVC 配置 -->
<servlet>
<servlet-name>springServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:contextConfigLocation-springService.xml</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

<!-- 事件* -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- shiro 权限控制的过滤器 -->

<!-- Spring 刷新Introspector防止内存泄露 -->
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>

<!-- session超时定义,单位为分钟 -->
<session-config>
<session-timeout>20</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<!-- 设置servlet编码开始 -->
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GB2312</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/</url-pattern>
</filter-mapping>
<!-- 设置servlet编码结束 -->

<display-name>Archetype Created Web Application</display-name>
</web-app>

<context-param>节点和<listener>节点是web项目启动时最先读取的两个节点,所以这两个节点里面所配置的内容是web项目启动时最先加载的部分。
<context-param>节点中配置的applicationContext.xml里面主要是数据库的配置信息,以及事务等等
<listener>节点配置的是web请求的*

2、applicationContext.xml 内容如下:

<?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" xmlns:context="http://www.springframework.org/schema/context"
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.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
">

<!-- 自动注解除Controller以外的Component -->
<context:component-scan base-package="com.weiluo.example">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>

<!-- 此配置可以让我们以${xxx}的形式来读取property.properties里面的信息 -->
<!-- <context:property-placeholder/> -->

<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>

<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driver}"></property>
<property name="url"
value="${jdbc.url}"></property>
<property name="username" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>

<!-- Connection Pooling Info -->
<property name="maxActive" value="${dbcp.maxActive}" />
<property name="maxIdle" value="${dbcp.maxIdle}" />
<property name="defaultAutoCommit" value="false" />
<!-- 连接Idle一个小时后超时 -->
<property name="timeBetweenEvictionRunsMillis" value="360000" />
<property name="minEvictableIdleTimeMillis" value="360000" />
</bean>

<!-- 配置SessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
p:dataSource-ref = "dataSource"
p:configLocation = "classpath:sqlMapConfig.xml" />

<!-- 采用spring与mybatis整合的第二种方法 -->
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>

<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
p:dataSource-ref = "dataSource" />

<!-- MapperScanner配置,自动搜索mapper里面的对象,并注入 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
p:basePackage = "com.weiluo.example.entity" />

<!-- 启动Spring注解事务 -->
<tx:annotation-driven/>

</beans>

3、web.xml中的<servlet>节点配置的是与请求处理相关的一些内容,主要是 url路由处理器,视图解析器,等等,如下:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">

<!-- url映射* -->
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="order" value="1" />
</bean>
<!-- 配置数据格式转换器 -->
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jsonHttpMessageConverter" />
</list>
</property>
</bean>
<bean id="jsonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
</bean>

<!-- 开启controller注解支持 -->
<!-- 注:如果base-package=cn.javass 则注解事务不起作用 TODO 读源码 -->
<context:component-scan base-package="com.weiluo.example.controller">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- 因为web-inf目录下面的静态资源文件是不能直接通过目录过去的,所以需要特殊声明-->
<mvc:resources location="/static/" mapping="/static/**" />

<!-- 视图解析器 -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="cache" value="true" />
<property name="prefix" value="" />
<property name="suffix" value=".html" />
<property name="exposeSpringMacroHelpers" value="true" />
<property name="exposeRequestAttributes" value="true" />
<property name="exposeSessionAttributes" value="true" />
<property name="requestContextAttribute" value="rc" />
<property name="contentType" value="text/html;charset=GB2312" />
<property name="order" value="0"/>
</bean>

<!-- 自定义的freemarker标签 -->
<bean id="blockDirective"
class="com.weiluo.example.freemarker.directive.BlockDirective" />
<bean id="extendsDirective"
class="com.weiluo.example.freemarker.directive.ExtendsDirective" />
<bean id="overrideDirective"
class="com.weiluo.example.freemarker.directive.OverrideDirective" />
<bean id="superDirective"
class="com.weiluo.example.freemarker.directive.SuperDirective" />

<!-- freemarker的配置项 -->
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/views/" />
<property name="freemarkerSettings">
<props>
<prop key="template_update_delay">5</prop>
<prop key="defaultEncoding">GB2312</prop>
<prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
<prop key="date_format">yyyy-MM-dd</prop>
<prop key="time_format">HH:mm:ss</prop>
<prop key="number_format">0.######</prop>
<prop key="whitespace_stripping">true</prop>
</props>
</property>
<property name="freemarkerVariables">
<map>
<entry key="extends" value-ref="extendsDirective"></entry>
<entry key="override" value-ref="overrideDirective"></entry>
<entry key="block" value-ref="blockDirective"></entry>
<entry key="super" value-ref="superDirective"></entry>
</map>
</property>
</bean>

</beans>

4、另外,一些常常变化的信息习惯于存放在application.properties文件里面,如:

#oracle version database setting
database=sqlserver
#jdbc.driver=oracle.jdbc.driver.OracleDriver
jdbc.driver=net.sourceforge.jtds.jdbc.Driver
#jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:jtds:sqlserver://127.0.0.1:1433;databaseName=SpringMyBatisExample
#jdbc.url=jdbc:mysql://localhost:3306/springmvcdemo
jdbc.username=sa
jdbc.password=sasa

#dbcp settings
dbcp.maxIdle=5
dbcp.maxActive=20

到这里,一个spring mvc的基本框架就已经搭建起来了。
后续再完成数据库mybatis的配置以及freemarker的配置。

Java程序员,最常用的20%技术有哪些

作为一名合格的Java程序员,你必须掌握以下二十种常用技术:

1.html、css

2.java工作原理(jvm)

3.java语法、数据结构和算法

4.java语言特性(封装、继承、多态、抽象)

5.java设计模式(在开发中会经常用到)

6.java反射机制(常用框架都会用到反射机制)

7.io(文件读写)

8.多线程

9.网络编程

10.javascript

11.jquery

12.数据库(oracle、mysql等等)

13.servlet

14.JDBC

15.javabean

16.WEB项目分层架构

17.前后台交互

18.ajax

19.过滤器及过滤器原理

20.常用框架(Struts、hibernate、spring、springMVC、i/mybatis)

总结来看,这些常用的主流技术,都具有招人方便, 学习成本低,上手容易的特点。

Java程序员,最常用的20%技术有哪些

Java的技术体系是非常庞大的,需要我们学习的技术非常多,往往很多初学的人,通过互联网查阅了一个庞大的学习列表,然后不知道如何下手。网上很多大牛列的技术不是不重要,但是掌握住企业应用的Java的核心技术,快速上手,是一种高效的学习手段。结合本人十余年的项目研发和带人经验,整理出如下方面。
首先JavaSE是核心,这是初学Java人员应最先接触学习的部分。Java的运行原理,jdk的配置,与jre的区别,基本数据类型,流程控制(顺序结构、选择结构、循环结构),数组、集合框架,异常处理等,这些都是比较容易学习的,需要多练习,在练习过程中加强理解。面向对象部分是Java初学者,尤其是没有任何编程语言基础的学起来有些难度,类、对象、继承、封装、多态等技术点需要多参照些现有的设计模型,学习设计的思路。诸如工厂模式、观察者模式、代理模式等重要的设计模式也是需要学习的,否则在将来应用框架时就会只知其然,不知其所以然。IO流、多线程也一定需要学习,尤其是XML、JSON等文件格式一定要掌握,这在数据交互时常用。
其次是数据库知识,作为初级Java程序员必须要掌握一种常用的关系型书库的应用,如MySQL或oracle等,数据库对象诸如表、视图等的创建、增删改查语句,尤其是查询,在企业中经常需要从十几张表、或几十张表中查询数据,所以对于如何进行内连接、外连接、以及联合查询等一定要掌握,另外对于索引、事务等也要掌握。
第三是Java Web部分,由于Java主要做web开发,一些前端技术HTML3、CSS5,javaScript,jQuery等这些不见得要学得有多深入,但是必须要掌握,tomcat、jsp,以及和数据库的交互这些都是必须要掌握的。
第四是框架部分,主流的ORM框架有Mybatis、hibernate,MVC框架有Spring MVC、Struts2等,可以优先掌握主流的SSM框架组合,框架的学习有人认为很简单,就按照规定、规范调用、使用呗,初学者可以先学习如何使用这些框架,然后慢慢的探究内部原理,因为框架是技术封装、简化的产物。
这里面有些同类型的技术比如hibernate,如果会使用Mybatis了,那么上手就会很容易,同理如果Spring MVC框架应用熟练了,那么Struts2框架其实就可以现学现卖了。
一个web程序包含的模块很多,不一定包括所有模块。
系统模块:Windows、Linux系统等。
存储模块:这里既包括关系型数据库MySQL、oracle等,也包括内存数据库redis、memcached等。
程序模块:还可以细化成持久化模块、业务逻辑模块、表现层模块,MVC框架的实现。
搜索模块:应用solr或Elasticsearch等。
服务器模块:tomcat、weblogic、Resion等
中间件模块:nginx、MQ消息队列技术等。
在这里额外说一下技术和技能的区别,初学者学一个技术可能很容易,但是这个技术如何在企业开发环境中应用这就是技能了,所以在学习的同时,要多应用,最好通过一些案例项目来学习,这样既高效,学习的还扎实。
补充一点,现在的应用级别越来越大,海量数据、高并发是处理的重点,单应用的程序已经无法满足要求,分布式是趋势,Dubbo、Zookeeper、Docker、SpringBoot、SpringCloud、MyCat等技术,包括上面系统模块里提到的一些技术都要学习的。

Java程序员,最常用的20%技术有哪些

Java的技术体系是非常庞大的,需要我们学习的技术非常多,往往很多初学的人,通过互联网查阅了一个庞大的学习列表,然后不知道如何下手。网上很多大牛列的技术不是不重要,但是掌握住企业应用的Java的核心技术,快速上手,是一种高效的学习手段。结合本人十余年的项目研发和带人经验,整理出如下方面。
首先JavaSE是核心,这是初学Java人员应最先接触学习的部分。Java的运行原理,jdk的配置,与jre的区别,基本数据类型,流程控制(顺序结构、选择结构、循环结构),数组、集合框架,异常处理等,这些都是比较容易学习的,需要多练习,在练习过程中加强理解。面向对象部分是Java初学者,尤其是没有任何编程语言基础的学起来有些难度,类、对象、继承、封装、多态等技术点需要多参照些现有的设计模型,学习设计的思路。诸如工厂模式、观察者模式、代理模式等重要的设计模式也是需要学习的,否则在将来应用框架时就会只知其然,不知其所以然。IO流、多线程也一定需要学习,尤其是XML、JSON等文件格式一定要掌握,这在数据交互时常用。
其次是数据库知识,作为初级Java程序员必须要掌握一种常用的关系型书库的应用,如MySQL或oracle等,数据库对象诸如表、视图等的创建、增删改查语句,尤其是查询,在企业中经常需要从十几张表、或几十张表中查询数据,所以对于如何进行内连接、外连接、以及联合查询等一定要掌握,另外对于索引、事务等也要掌握。
第三是Java Web部分,由于Java主要做web开发,一些前端技术HTML3、CSS5,javaScript,jQuery等这些不见得要学得有多深入,但是必须要掌握,tomcat、jsp,以及和数据库的交互这些都是必须要掌握的。
第四是框架部分,主流的ORM框架有Mybatis、hibernate,MVC框架有Spring MVC、Struts2等,可以优先掌握主流的SSM框架组合,框架的学习有人认为很简单,就按照规定、规范调用、使用呗,初学者可以先学习如何使用这些框架,然后慢慢的探究内部原理,因为框架是技术封装、简化的产物。
这里面有些同类型的技术比如hibernate,如果会使用Mybatis了,那么上手就会很容易,同理如果Spring MVC框架应用熟练了,那么Struts2框架其实就可以现学现卖了。
一个web程序包含的模块很多,不一定包括所有模块。
系统模块:Windows、Linux系统等。
存储模块:这里既包括关系型数据库MySQL、oracle等,也包括内存数据库redis、memcached等。
程序模块:还可以细化成持久化模块、业务逻辑模块、表现层模块,MVC框架的实现。
搜索模块:应用solr或Elasticsearch等。
服务器模块:tomcat、weblogic、Resion等
中间件模块:nginx、MQ消息队列技术等。
在这里额外说一下技术和技能的区别,初学者学一个技术可能很容易,但是这个技术如何在企业开发环境中应用这就是技能了,所以在学习的同时,要多应用,最好通过一些案例项目来学习,这样既高效,学习的还扎实。
补充一点,现在的应用级别越来越大,海量数据、高并发是处理的重点,单应用的程序已经无法满足要求,分布式是趋势,Dubbo、Zookeeper、Docker、SpringBoot、SpringCloud、MyCat等技术,包括上面系统模块里提到的一些技术都要学习的。

springmvc mybatis怎么把mysql的时间格式化为yyyy-mm-dd展示到前台

查询出数据后再处理成yyyy-MM-dd的形式,然后返回前台页面.查出数据后,用simpleDateFormat对时间进行格式化。

MySQL 是一个关系型数据库,由瑞典 MySQL AB 公司开发,目前属于 Oracle 旗下公司。MySQL 最流行的关系型数据库管理系统,在 WEB 应用方面 MySQL 是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件之一。MySQL 是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。MySQL 所使用的 SQL 语言是用于访问数据库的最常用标准化语言。MySQL 软件采用了双授权(本词条"授权"),它分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择 MySQL 作为网站数据库。由于其社区版的性能卓越,搭配 PHP ,Linux和 Apache 可组成良好的开发环境,经过多年的web技术发展,在业内被广泛使用的一种web服务器解决方案之一,称之为LAMP。

Java程序员,最常用的20%技术有哪些?

两个月,这让我想到了我当年第一份工作,也是两个月从零学JAVA。当时就买了3本书,强啃了6周。

记住一点,你要抓重点,你只要让人家知道,你足够初级开发就可以了,学了长长一个列表,个个不精,被面试官随便问起来,就糟了。倒不如抓住最基本的,反正你就是初级人员,只懂最基本的,是最正常的情况。

首先,学会一个J2EE服务器,tomcat (Nginx或者httpd等web服务),学会的标准是,会下载,能启动,知道什么文件部署在什么地方,能看到启动画面,能知道最直接,最关键的配置文件名字和位置。你要了解下其他的服务器的名字,就足够了。有人叫你去学weblogic?那是坑你,2个月weblogic,你最多也只能懂十分之一。太重。

其次,学一个框架,以前SSH,现在SSM,这些都多余,你就只看spring MVC,因为所有的mvc框架都类似,你只要坚持你了解MVC,其他的我觉得是容易借鉴类推的,H和M,你就直接说,我没有项目经验,我是没有实际接触过的,我只了解一点点原理,这个不要花时间,最后去看几眼文档就可以了。spring MVC,就这么简单,一个就行。

然后是数据库,别赶时髦搞nosql,老老实实关系型,mysql就很好,坑浅应用多,最近连集群支持的都很好了,你只要强调一点,数据库,你不是DBA,你还不懂如何调优,如何调执行计划,你只懂增删改查,所以你要学的就是T-SQL,标准是你能手写带条件的增删改查,会复杂语句更好,稍微了解下sql效率方面的问题,为了面试也是可以。MSSQL在国内被鄙视的不行,如果有人叫你弄oracle,那又是太装,我手下一票的5年程序员,其中有超过一半连oracle的AWR都不会读,有的连数据字典都不知道。

IDE不多谈,你总逃不过eclipse和几个大厂的东西。要用简单易用的,别花太多时间在这个上面。

设计模式你要稍微看一下,了解什么是设计模式,你大可以老实说,你根本刚入行,只是粗通工厂模式和单粒,其他的需要在工作中学习,这样既不会显得完全不懂,也不会出什么纰漏。

程序方面,jdbc需要了解下,相关的有连接字的写法,如何准备和获取结果,什么是resultset这类东西,当然,数据库连接的关闭和释放也是需要的。

类和抽象类和接口的关系搞清楚,继承和实现搞清楚,重载重写搞清楚这些都是基本概念。

EJB现在不太用了,稍微了解下,你可以用spring所以不用手写EJB了。spring除了MVC以外,还有很多项目,DAO可以看一下,比较初级。

由于java主要是B/S结构,无论是集成还是自己的前后端,你都要看一下http,整个http的生命周期是什么?存在哪些步骤和不同的application负责哪个阶段,相关的有几个request和response实体,包含什么是session了解下。

业务逻辑的话,上手仔细写几个例子就好了

前段你不需要了解太多,JSP JS就足够了,你是程序员,不是前端的美工,不用去了解太多。jsp上有个容易忽视的基础点:tag到底是什么如何处理。jsp的生命周期这些也最好看一下。

基础的devops稍微了解下, git的代表,github可以注册一个账号,搞清楚本地repo和远程repo之间的关系即可。SVN更为简单一点。

Maven也要学习一下,主要是pom文件的几个主要的部分,尤其是depedency。

code smells方面手写万把行代码。自己有个感觉,不用去刻意背javadoc。

去面试吧,祝你好运!

Top