白沙洲大桥数据可视化平台开发——经验积累

来源:互联网 发布:阿里云服务器转移账户 编辑:程序博客网 时间:2024/04/27 14:30

一、静态资源取消拦截

web.xml配置取消拦截webapp目录下的某个文件夹的所有内容

<servlet-mapping>        <servlet-name>default</servlet-name>        <url-pattern>/library/*</url-pattern>        <url-pattern>*.js</url-pattern>    </servlet-mapping>

二、配置数据源连接sqlserver2008r2

jar包下载地址:
SQL SERVER2008:Microsoft SQL Server JDBC Driver 2.0
下载地址:http://www.microsoft.com/downloads/details.aspx?familyid=99B21B65-E98F-4A61-B811-19912601FDC9&displaylang=zh-cn
SQL SERVER2008 R2:Microsoft SQL Server JDBC Driver 3.0
下载地址:http://www.microsoft.com/downloads/zh-cn/details.aspx?familyid=A737000D-68D0-4531-B65D-DA0F2A735707&displaylang=zh-cn#filelist
SQL SERVER2008和SQL SERVER2008 R2的下载地址是不一样的,本系统用的R2,下载第二个。
jdk1.6及以后的版本使用sqljdbc4.jar.

sqljdbc4.jar

2.1 配置文件jdbc.properties

jdbc.user=sajdbc.password=abc123jdbc.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriverjdbc.url=jdbc:sqlserver://localhost:1433;database=Test170331;integratedSecurity=falsejdbc.initialPoolSize=5jdbc.maxPoolSize=10

其中,integratedSecurity=false表示不使用windows用户认证。

2.2 配置文件applicationContext-datasource.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:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">    <!-- 导入资源文件 -->    <context:property-placeholder location="classpath:jdbc.properties"/>    <!-- 配置C3P0数据源 -->    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">        <property name="user" value="${jdbc.user}"></property>        <property name="password" value="${jdbc.password}"></property>        <property name="jdbcUrl" value="${jdbc.url}"></property>        <property name="driverClass" value="${jdbc.driverClassName}"></property>        <property name="initialPoolSize" value="${jdbc.initialPoolSize}"></property>        <property name="maxPoolSize" value="${jdbc.maxPoolSize}"></property>    </bean></beans>

使用c3p0需要添加相关jar包c3p0-0.9.1.2.jar
c3p0-0.9.1.2.jar

三、JSP 标准标签库

JSP 标准标签库(JSTL)
http://www.runoob.com/jsp/jsp-jstl.html
从Apache的标准标签库中下载的二进包(jakarta-taglibs-standard-current.zip)。
官方下载地址:http://archive.apache.org/dist/jakarta/taglibs/standard/binaries/
下载jakarta-taglibs-standard-1.1.2.zip 包并解压,将jakarta-taglibs-standard-1.1.2/lib/下的两个jar文件:standard.jar和jstl.jar添加到项目中。
这里写图片描述
taglibs.jsp文件包含标签库声明语句,在需要用到jstl标签库页面的页面添加

<%@ include file="/views/include/common/taglibs.jsp"%>
<%-- taglib --%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %><%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>

3.1 applicationScope的使用

新建i18n.jsp文件

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><c:if test="${applicationScope.initString == null}">    <c:set var="initString" scope="application" value="false"/></c:if><c:if test="${applicationScope.initString!='true'}">    <c:set var="initString" scope="application" value="true"/>    <c:set var="textSystemTitle" scope="application" value="白沙洲大桥安全监测数据可视化展示平台"/>     <!-- 这里可以添加很多applicationScope内容 --></c:if>

在需要用到的页面<head></head>中添加

<%@ include file="/views/include/i18n.jsp"%>

然后在body的底部从i18n.jsp获取需要的值,就可以使用了。

<script type="text/javascript">    var i18nString = {            "textSystemTitle":'${applicationScope.textSystemTitle}'        };    </script>

四、desktio.jsp结构调整

随着开发框架需要,desktop.jsp的<head></head>包含的内容越来越多,现将引用的内容分类,分别放在meta.jsp和normal.jsp里面。其中normal.jsp包含了JSTL需要引用的标签和包含 applicationScope 的i18n.jsp文件。

<!-- JSTL需要引用的标签和包含 applicationScope 的i18n.jsp文件 --><%@ include file="/views/include/common/taglibs.jsp"%><%@ include file="/views/include/i18n.jsp"%>

meta.jsp则包含了一些meta信息和bootstrap的css信息等。meta.jsp文件的内容为:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator"    content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39" /><meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1" /><!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --><!-- Bootstrap --><link href="library/bootstrap/css/bootstrap.css" rel="stylesheet" /><!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --><!-- WARNING: Respond.js doesn't work if you view the page via file:// --><!--[if lt IE 9]>     <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>     <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>     <![endif]-->

调整之后,desktop.jsp文件的body以上的内容看起来就清晰一些:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ include file="/views/include/common/normal.jsp"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><%@ include file="/views/include/common/meta.jsp"%><title>${applicationScope.textSystemTitle}</title><script type="text/javascript" src="require.js" data-main="main"></script><script type="text/javascript">    require([ "desktop"]);</script></head>

五、requireJS缓存,导致请求相同页面时,页面初始化代码不会执行

六、log4j配置问题

七、SpringMvc集成hibernate问题

0 0
原创粉丝点击