在jsp页面加入如下句:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
String.format = function() {if( arguments.length == 0 )
return null
var str = arguments[0]
for(var i=1i<arguments.lengthi++) {
var re = new RegExp('\\{' + (i-1) + '\\}','gm')
str = str.replace(re, arguments[i])
}
return str
}
这是js里面的format函数,使用和C#里面一样的
var a = String.format('{0}{1}', 0, 1)
你自己可以去试试看,100%成功
先安装package control,如果你已经安装了package control,按ctrl+shift+p,调出面板,然后在面板里输入install package,按回车确定。然后再在下一个面板里输入jsformat,按回车确定,就自动安装了。如果你还没有安装package control。 从菜单 View - Show Console 或者 ctrl + ~ 快捷键,调出 console。将以下 Python 代码粘贴进去并 enter 执行。,这个是安装sublime text2的。import urllib2,ospf='Package Control.sublime-package'ipp =
sublime.installed_packages_path()os.makedirs( ipp ) if not os.path.exists(ipp)
else Noneurllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler(
)))open( os.path.join( ipp, pf), 'wb' ).write( urllib2.urlopen(
'http://sublime.wbond.net/' +pf.replace( ' ','%20' )).read())print( 'Please
restart Sublime Text to finish installation')