`
jd406
  • 浏览: 47926 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
js 如何动态增加下拉框列表,下拉框里的内容从js数组里得来?
<html>
<head>
</head>
<body>
<select id="collect" onclick="fun()"></setect>
<option>AAA</option>
<option>BBB</option>
<script type="text/javascript">
var tom=['CCC','DDD']
var collect=document.getElementById("collect")
	var old=collect.innerHTML
	var fun =function(){
	
	var niw=" "
	for(var i=0;i<tom.length;i++){
		niw+='<option>'+tom[i]+'</option>';
	}
	collect.innerHTML=old+niw
	
}
</script>
</body>
</html>
Spring整合FreeMarker配置 Spring整合FreeMarker配置
tag_syntax=auto_detect
template_update_delay=60
default_encoding=UTF-8
output_encoding=UTF-8
locale=zh_CN
date_format=yyyy-MM-dd
time_format=HH:mm:ss
datetime_format=yyyy-MM-dd HH:mm:ss
classic_compatible=true
template_exception_handler=ignore
Spring整合FreeMarker配置 Spring整合FreeMarker配置
<?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:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

	<!-- 配置freeMarker的模板路径 -->
	<bean id="freemarkerConfig"
		class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
		<property name="templateLoaderPath" value="/WEB-INF/view/" />
		<property name="freemarkerVariables">
			<map>
				<entry key="xml_escape" value-ref="fmXmlEscape" />
				<entry key="webRoot" value="${webRoot}"></entry>
				<entry key="jsRoot" value="${jsRoot}"></entry>
			</map>
		</property>
		<!-- FreeMarker默认每隔5秒检查模板是否被更新,如果已经更新了,就会重新加载并分析模板。 但经常检查模板是否更新可能比较耗时。如果你的应用运行在生产模式下,而且你预期模板不会经常更新, 
			则可以将更新的延迟时间延长至一个小时或者更久。 可以通过为freemarkerSettings属性设置template_update_delay达到这一目的 -->
		<property name="freemarkerSettings">
			<props>
				<prop key="template_update_delay">3600</prop>
				<prop key="tag_syntax">auto_detect</prop><!-- 设置标签类型 两种:[] 和 <> 。[] 这种标记解析要快些 -->
				<prop key="default_encoding">UTF-8</prop>
				<prop key="output_encoding">UTF-8</prop>
				<prop key="locale">zh_CN</prop>
				<prop key="date_format">yyyy-MM-dd</prop>
				<prop key="time_format">HH:mm:ss</prop>
				<prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
				<prop key="number_format">#</prop><!-- 设置数字格式 以免出现 000.00 -->
				<prop key="classic_compatible">true</prop><!-- 可以满足一般需要。默认情况变量为null则替换为空字符串,如果需要自定义,写上${empty!"EmptyValue of fbysss"}的形式即可  -->
				<prop key="template_exception_handler">html_debug</prop><!-- ignore,debug,html_debug,rethrow -->
			</props>
		</property>
		<!-- 一下语句可以也可以配置freemarkerSettings属性,代码更为简洁 -->
		<!-- <property name="freemarkerSettings" ref="freemarkerConfiguration"></property> -->
	</bean>
	
	<bean id="freemarkerConfiguration"
		class="org.springframework.beans.factory.config.PropertiesFactoryBean">
		<property name="location" value="classpath:freemarker.properties" />
	</bean>

	<bean id="fmXmlEscape" class="freemarker.template.utility.XmlEscape" />

	<!-- 配置freeMarker视图解析器 -->
	<!-- FreeMarker视图解析 如返回student,在这里配置后缀名ftl和视图解析器 -->
	<bean id="viewResolver"	class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">

		<property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"/>
		<property name="cache" value="true"/>
		<property name="suffix" value=".ftl" />
		<property name="contentType" value="text/html;charset=UTF-8" />
		<property name="requestContextAttribute" value="request" />
		<!-- 将请求和会话属性作为变量暴露给FreeMarker模板使用。要做到这一点,可以设置exposeRequestAttributes或者exposeSessionAttributes为true -->
		<property name="exposeRequestAttributes" value="true" />
		<property name="exposeSessionAttributes" value="true" />
		<!-- 使用这些宏,必须设置FreeMarkerViewResolver的exposeMacroHelpers属性为true -->
		<property name="exposeSpringMacroHelpers" value="true" />
	</bean>

	<context:component-scan base-package="cn.com.tcgroup.freemarker">
		<context:include-filter type="regex" expression=".*.web.*" />
	</context:component-scan>

	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />

	<context:component-scan base-package="cn.com.tcgroup.freemarker.*.dao.impl" />
	<context:component-scan base-package="cn.com.tcgroup.freemarker.*.service.impl" />

</beans>
spring定时器配置 Spring定时器的使用
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	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.0.xsd">
	<!-- 每个定义的任务都要在这里进行引用才能运行 -->
	<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="triggers">
			<list>
				<ref local="BusinessTestTrigger" />
			</list>
		</property>
	</bean>
	<!-- 定义我们要运行的类,可以使用注入定制一些参数 -->
	<bean id="BusinessTestTime" class="com.test.Test">
		<property name="para" value="Spring定时器测试V1" />
	</bean>
	<!-- 引用,配置要运行的方法 -->
	<bean id="BusinessTestDetail"
		class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<property name="targetObject">
			<ref bean="BusinessTestTime" />
		</property>
		<property name="concurrent" value="false" />
		<property name="targetMethod" value="run" />
	</bean>
	<!-- 引用,定制调用间隔,具体时间配置的正则,请阅读readme.txt -->
	<bean id="BusinessTestTrigger"
		class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail">
			<ref bean="BusinessTestDetail" />
		</property>
		<property name="cronExpression">
			<value>0/5 * * * * ?</value>
		</property>
	</bean>	
</beans>
EL 字符串截取方法总结
${fn:substring(todo.description,fn:indexOf(todo.description,2),fn:length(todo.description))}
struts2 标签 字符串截取方法总结
<s:textfield label="日期" name="todo.created" readonly="true">
      <s:param name="value">
	<s:date name="#attr.todo.created" format="yyyy-MM-dd HH:mm:ss"/>
      </s:param>
</s:textfield>
EL表达式的常见使用方法 EL 表达式学习
1.普通字符串 

request.setAttribute("hello", "hello world"); 

---------------------------------------------El表达式获取 
<li>普通字符串</li><br> 
hello(jsp脚本):<%=request.getAttribute("hello") %><br> 
hello(el表达式,el表达式的使用方法$和{}):${hello }<br> 
hello(el表达式,el的隐含对象pageScope,requestScope,sessionScope,applicationScope, 
<br> 如果未指定scope,它的搜索顺序pageScope~applicationScope):${requestScope.hello }<br> 
hello(el表达式,scope=session):${sessionScope.hello }<br> 

--------------------------------------------页面输出 
.普通字符串 
hello(jsp脚本):hello world 
hello(el表达式,el表达式的使用方法$和{}):hello world 
hello(el表达式,el的隐含对象pageScope,requestScope,sessionScope,applicationScope, 
如果未指定scope,它的搜索顺序为pageScope~applicationScope):hello world 
hello(el表达式,scope=session): 
<><><><><><><><><><><><><><><><><><><> 

2.结构 

Group group = new Group(); 
group.setName("尚学堂"); 

User user = new User(); 
   user.setUsername("张三"); 
   user.setAge(18); 
   user.setGroup(group); 
  
request.setAttribute("user", user); 

---------------------------------------------El表达式获取 
<li>结构,采用.进行导航,也称存取器</li><br> 
姓名:${user.username }<br> 
年龄:${user.age }<br> 
所属组:${user.group.name }<br> 

--------------------------------------------页面输出 
.结构,采用.进行导航,也称存取器 
姓名:张三 
年龄:18 
所属组:尚学堂 
<><><><><><><><><><><><><><><><><><><> 

3.map 
Map mapValue  = new HashMap(); 
   mapValue.put("key1", "value1"); 
   mapValue.put("key2", "value2"); 

request.setAttribute("mapvalue", mapValue); 


---------------------------------------------El表达式获取 
<li>输出map,采用.进行导航,也称存取器</li><br> 
mapvalue.key1:${mapvalue.key1 }<br> 
mapvalue.key2:${mapvalue.key2 }<br> 

--------------------------------------------页面输出 
.输出map,采用.进行导航,也称存取器 
mapvalue.key1:value1 
mapvalue.key2:value2 
<><><><><><><><><><><><><><><><><><><> 

4.字符串数组 
String[] strArray = new String[]{"a", "b", "c"}; 
request.setAttribute("strarray", strArray); 

User[] users = new User[10]; 
  for (int i=0; i<10; i++) { 
User u = new User(); 
u.setUsername("U_" + i); 
users[i] = u; 
  } 
request.setAttribute("users", users); 

---------------------------------------------El表达式获取 
<li>输出对象数组,采用[]和下标</li><br> 
userarray[3].username:${users[2].username }<br> 

--------------------------------------------页面输出 
.输出对象数组,采用[]和下标 
userarray[3].username:U_2 
<><><><><><><><><><><><><><><><><><><> 

5.ArrayList 
List userList = new ArrayList(); 
   for (int i=0; i<10; i++) { 
User uu = new User(); 
uu.setUsername("UU_" + i); 
userList.add(uu); 
   } 
request.setAttribute("userlist", userList); 

---------------------------------------------El表达式获取 
<li>输出list,采用[]和下标</li><br> 
userlist[5].username:${userlist[4].username }<br> 

--------------------------------------------页面输出 
输出list,采用[]和下标 
userlist[5].username:UU_4 
<><><><><><><><><><><><><><><><><><><> 

6.empty 
request.setAttribute("value1", null); 
request.setAttribute("value2", ""); 
request.setAttribute("value3", new ArrayList()); 
request.setAttribute("value4", "123456"); 

---------------------------------------------El表达式获取 
<li>el表达式对运算符的支持</li><br> 
1+2=${1+2 }<br> 
10/5=${10/5 }<br> 
10 div 5=${10 div 5 }<br> 
10%3=${10 % 3 }<br> 
10 mod 3=${10 mod 3 }<br> 
<!-- 
   ==/eq 
   !=/ne 
   </lt 
   >/gt 
   <=/le 
   >=/ge 
   &&/and 
   ||/or 
   !/not 
   //div 
   %/mod 
  -->  
js回车事件的捕捉 JS按回车登录系统代码(各浏览器兼容)
<script type="text/javascript">

	//按下回车登录系统
	document.onkeydown = function(event){
		event = event?event:window.event;
		if (event.keyCode == 13) {
			alert("hello world!");
		}
	};
</script>
Global site tag (gtag.js) - Google Analytics