专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > jQuery

spring-mvc 与jquery-easyui-layout调整

发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
spring-mvc 与jquery-easyui-layout整合

开发环境


spring-webmvc-4.0.8.RELEASE

Jquery-easyui-1.4.0

以上是在整合layout页面所用的各自版本号。


配置


Spring-mvc.xml配置



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
	xmlns:mvc="http://www.springframework.org/schema/mvc" 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
	http://www.springframework.org/schema/context
	http://www.springframework.org/schema/context/spring-context-3.0.xsd
	http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
	http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
">

	<mvc:annotation-driven />
		
	
	<!-- EasyUI样式,JS配置 -->
	<mvc:resources location="/demo/" mapping="/demo/**"></mvc:resources>
	<mvc:resources location="/locale/" mapping="/locale/**"></mvc:resources>
	<mvc:resources location="/plugins/" mapping="/demo/**"></mvc:resources>
	<mvc:resources location="/themes/" mapping="/themes/**"></mvc:resources>
	<mvc:resources location="/page/" mapping="/page/**"></mvc:resources>

	<mvc:resources location="/" mapping="/**"></mvc:resources>
	
	
</beans>

这里需要注意的就是在文件头信息内配置

http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd

这个主要还是配合后面针对MVC对于特定资源拦截所做的处理,不然对于前台js以及css等资源是无法去访问的。



Web.xml配置



<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <display-name>Archetype Created Web Application</display-name>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:applicationContext-*.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/spring-mvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

其实这个主要还是针对特定的action的相关配置,这里需要注意的是

<span style="font-family:KaiTi_GB2312;font-size:18px;">schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"</span>


这个的配置主要是用来解决前台对于jsp内去书写EL表达式来进行的处理。



jsp配置



<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- 启用EL表达式 -->
<%@ page isELIgnored="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>模板管理</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/themes/icon.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/demo/demo.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/jquery.easyui.min.js"></script>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/themes/default/easyui.css">

<span style="color:#ff0000;"><strong>1:<%@ page isELIgnored="false"%></strong></span>


这个主要还是用来去启用在jsp内书写的el表达式。


<strong><span style="color:#ff0000;">2.${pageContext.request.contextPath}</span></strong>


这是主要是用来获取web端的资源根目录。


资源页读取配置


添加tab读取资源文件


这里demo内还是用的是实在的jsp页面,其实在开发过程中,每个tab的增加都需要访问还是各自的资源文件对应

的controller或者发布好的jndiname即可。


js 函数


<script type="text/javascript">
/**  
 * 创建新选项卡  
 * @param tabId    选项卡id  
 * @param title    选项卡标题  
 * @param url      选项卡远程调用路径  
 */  
function addTab(tabId,title,url){  
    //如果当前id的tab不存在则创建一个tab  
    if($("#"+tabId).html()==null){  
        var name = 'iframe_'+tabId;  
        $('#centerTab').tabs('add',{  
            title: title,           
            closable:true,  
            cache : false,  
            //注:使用iframe即可防止同一个页面出现js和css冲突的问题  
            content : '<iframe name="'+name+'"id="'+tabId+'"src="'+url+'" width="100%" height="100%" frameborder="0" scrolling="auto" ></iframe>'  
        });  
    }  
} 

页面的配置


这个主要还是根据jquery定义好的class直接用就可以了。


!-- 主界面的框架 -->
<body class="easyui-layout">
	<!-- 北边区域 -->
	<div data-options="region:'north',border:false" style="height:60px;background:#B3DFDA;padding:10px">考试系统</div>
	<!-- 各个模块 -->
	<div data-options="region:'west',split:true,title:'功能索引'" style="width:150px;padding:10px;">
		<!-- 子模块:模板管理 -->
		<div class="easyui-accordion" data-options="fit:true,border:false">
			 <div title="模板配置" style="padding:10px;">  
			       	<li><a href="javascript:addTab('tabId_templet','模板管理','templetMain.jsp');">模板管理</a></li>
			       	<li><a href="javascript:addTab('tabId_datagrid','datagrid模板','page/datagrid.jsp');">datagrid</a></li>                                      
			  </div>		
		</div>
	</div>	
	<!-- 东部区域 -->
	<div data-options="region:'east',split:true" style="width:10px;padding:10px;"></div>
	<!-- 底部 -->
	<div data-options="region:'south',border:false" style="height:50px;background:#A9FACD;padding:10px;">
		<div id="footer">Copyright &copy; 2014     TGB-9        廊坊师范学院信息技术提高班</div>
	</div>
	<!-- 中央布局 -->
	<div data-options="region:'center'"  fit="true" border="false" >
		<div class="easyui-tabs" id="centerTab" fit="true" border="false">  
            <div title="欢迎页" style="padding:20px;overflow:hidden;">   
                <div style="margin-top:20px;">  
                    <h3>你好,欢迎来到系统</h3>  
                </div>  
            </div>  
        </div>  
	</div>
</body>


效果图







友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

  • jQuery搜索框输入文字下拉揭示菜单

    jQuery搜索框输入文字下拉提示菜单 jQuery搜索框输入文字下拉提示菜单 原文地址: http://www.jq22.com/jquery-info6193 ...

  • 7个替开发者准备的有用的jQuery技巧

    7个为开发者准备的有用的jQuery技巧 一、在新窗口打开链接 用下面的代码,你点击链接即可在新窗口打开: $(document).ready(fu...

  • jQuery获取呼应Input例子

    jQuery获取相应Input例子 页面上有许多input框,使用的是EasyUI样式,中间还参杂着各种其他无id的Input框,如下: <input class=...

  • webpack 引出jquery和第三方jquery插件

    webpack 引入jquery和第三方jquery插件 1、引入jquery jQuery 直接在 html 中引入,然后在 webpack 中把它配置为全局即可。 index....

  • JQuery的开发与使用经验

    JQuery的开发与使用心得 关于jQuery的 入门使用jQuery可以很容易或具有挑战性的,这取决于你如何使用JavaScript,HTML,CSS进行开发和...

  • 深入学习jQuery卡通片控制

    深入学习jQuery动画控制 &times; 目录 [1]动画状态 [2]停止动画 [3]动画延迟[4]全局控制 前面的话   jQuery动画可以使用fade、...

  • jquery操作table报表

    jquery操作table表格 一、数据准备 <table id="table1"> <tr><th>文章标题</th><th>文章分类</th><th>发布时间</th><th>...

  • html + css + jquery实现简略的进度条实例

    html + css + jquery实现简单的进度条实例 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-eq...

  • jquery中ajax方法的datatype的功用

    jquery中ajax方法的datatype的作用 今天在维护一个项目的时候遇见了一个小问题。但是这个问题我认为对于项目十分有帮助。...

  • jQuery菜单示范(全选,反选,取消)

    jQuery菜单示例(全选,反选,取消) 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <titl...

热门推荐: