我需要在jinja2中格式化十进制数字.
当我需要格式化日期时,我在模板中调用strftime()方法,如下所示:
{{ somedate.strftime('%Y-%m-%d') }}
Run Code Online (Sandbox Code Playgroud)
我想知道是否有类似的方法来做这个数字.
提前致谢!
如何使用JSTL在jsp页面内拆分用"/"分隔的字符串?
我有一个这种格式的字符串:**
"23/11/2010"
*.有时,字符串可能是这样的:*
"1/1/2010"
*.我需要做一些事情才能将字符串拆分为三个不同的子字符串:*
"23","11","2010".
**这是因为我需要将它们中的每一个放在三个不同的文本字段中,如下所示:
<input type="text" value="23">/
<input type="text" value="11">/
<input type="text" value="2010">
Run Code Online (Sandbox Code Playgroud)
我还找不到任何有用的例子.
提前致谢!
我正在试图理解管理UI交互的三种方法之间的差异.
在真实案例中试图弄清楚时,我真的很困惑这三个术语.
下面的代码显示了invokeAndWait方法的功能,但如果我用invokeLater或getEventLock()替换它,程序将以完全相同的方式工作.
有人可以修改代码,以显示更新UI的三种方法之间的差异吗?
public final class HelloWorldMainScreen extends MainScreen
{
private LabelField labelField;
public HelloWorldMainScreen()
{
labelField = new LabelField("Hello World");
add(labelField);
MainScreenUpdaterThread thread = new MainScreenUpdaterThread(this);
thread.start();
}
public void appendLabelText(String text){
labelField.setText(labelField.getText()+"\n"+text);
}
}
public class MainScreenUpdaterThread extends Thread {
HelloWorldMainScreen mainScreen;
public MainScreenUpdaterThread(HelloWorldMainScreen mainScreen){
this.mainScreen = mainScreen;
}
public void run(){
for (int i = 0; i < 10; i++) {
try{
Thread.sleep(5000);
}catch(InterruptedException ex){};
UiApplication.getUiApplication().invokeAndWait(new Runnable() {
public void run() {
mainScreen.appendLabelText("Update");
}
});
} …Run Code Online (Sandbox Code Playgroud) 这是我的表格:
<form action="/Admin/usuarios/obtener_valores" method="POST">
<div class="span-16">
<input type="hidden" value="1" name="usuarioPinIdHidden" id="usuarioPinIdHidden">
<table class="summary" style="border: none;">
<tr>
<td colspan="2">¿A que edad tuvo sus primeras vacaciones?</td>
</tr>
<tr>
<td colspan="2"><input id="text@'+1+^+1" name="respuesta[0].respuesta" type="text" value=""/></td>
</tr>
<tr>
<td colspan="2">¿Estaba casado en 1991?</td>
</tr>
<tr>
<td colspan="2"><input id="boolean@'+3+^+1" name="respuesta[1].respuesta" type="radio" value="true"/>
<label for="boolean@'+3+^+1">Si</label>
<br />
<input id="boolean@'+3+^+1" name="respuesta[1].respuesta" type="radio" value="false"/>
<label for="boolean@'+3+^+1">No</label></td>
</tr>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
这是在单击提交按钮后打印所有id值的功能:
$(document).ready(function() {
$('form').submit(function (){
return verificarRespuestas();
});
});
function verificarRespuestas(){
alert('hola');
$('form').children().each(function(){
var child = $(this);
alert(child.id);
}); …Run Code Online (Sandbox Code Playgroud) 我需要制作下表,圆角和不同颜色的表体:

这是我的表:
<table class="form_caja">
<tr><th>Referidos</th></tr>
<tr><td>Numero</td><td>Companhia</td><td>Nombre</td><td>Apellido</td><td>Email</td></tr>
<tr><td>0976343344</td><td>PERSONAL</td><td>f</td><td>asd</td><td></td></tr>
<tr><td>0992123123</td><td>CLARO</td><td>dA</td><td>de</td><td></td></tr>
<tr><td>0963555457</td><td>CLARO</td><td>f</td><td>sdf</td><td></td></tr>
<tr><td>0963555345</td><td>CLARO</td><td>e</td><td>de</td><td></td></tr>
</table>
Run Code Online (Sandbox Code Playgroud)
这是风格:
.form_caja {
width: 524px;
padding-top: 8px;
padding-bottom: 15px;
margin: 0 auto 20px auto;
background: #446bb3;
border-radius: 15px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
color: #446bb3;
}
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止所得到的:

如何获得所需的表格呢?
这是我视图的一个片段,当点击超链接时,我需要将两个名为solicitudId和detailId的参数发送到控制器中的方法
<tr>
<td>${user.loginName}</td>
<td>${user.phone}</td>
<td>${user.address}</td>
<td><a href="/enable?solicitudId=${user.solicitudId}&detailId=${user.detail}">Enable</a></td>
tr>
Run Code Online (Sandbox Code Playgroud)
//控制器
@RequestMapping(value="/enable", method=RequestMethod.GET)
public String enableUser(Model model){
try{
//How should I get the values from the parameters solicitudId and detailId?
}catch(Exception e){
e.printStackTrace();
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
提前致谢!
对不起,我知道这个问题很简单,但我不知道如何从返回的字典中获取响应数据:
这是我的jQuery.get()方法:
$("#selectDireccion").change(function() {
$("select option:selected").each(function() {
if ($(this).index() != 0) {
valorKeyId = $(this).val()
$.get("/ajaxRequest?opcion=obtenerSedeKeyId", {
keyId: valorKeyId
}, function(data) {
alert(data)
});
}
});
});?
Run Code Online (Sandbox Code Playgroud)
这是警报打印的内容:
{"name": "First Value", "phone": "434534"}
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能从字典的'name'键中获取值?
这样data.name的警告内部有没有效果.
谢谢!
对不起标题,但我不知道如何总结这个问题= /
我需要制作一个这样的屏幕:

如您所见,它显示了每个内部都包含UI元素的"框".
每个"盒子"都放在像某种桌子的细胞里面.
我认为将"盒子"表示为具有垂直滚动的TableLayoutManager中的单个屏幕是个好主意,但我甚至不知道这是否可靠.
请有人告诉我如何在BlackBerry上做类似的事情,因为我不知道从哪里开始.
我正在使用BlackBerry JRE 4.5.0
提前致谢!
编辑:我编辑这个答案只是为了表明用户Nate提供的解决方案有多好:

这是我的字典:
[{'entity': 'first entity', 'place': ['first', 'second', 'abc']}, {'entity': 'second entity', 'place': ['awe', 'ert']}]
Run Code Online (Sandbox Code Playgroud)
我想以这种方式打印值:
-first entity
-first, second, abc
-second entity
-awe, ert
Run Code Online (Sandbox Code Playgroud)
我尝试了很多东西,但我不知道如何处理第二个键的列表
你能否建议我如何在Django模板中做同样的事情?
提前致谢
我知道这是有效的:
def printValue():
print 'This is the printValue() method'
def callPrintValue(methodName):
methodName()
print 'This is the callPrintValue() method'
Run Code Online (Sandbox Code Playgroud)
但有没有办法传递一个接收参数作为另一个函数的参数的方法?
这样做是不可能的:
def printValue(value):
print 'This is the printValue() method. The value is %s'%(value)
def callPrintValue(methodName):
methodName()
print 'This is the callPrintValue() method'
Run Code Online (Sandbox Code Playgroud)
这是我得到的堆栈跟踪:
This is the printValue() method. The value is dsdsd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in callPrintValue
TypeError: 'NoneType' object is not callable
Run Code Online (Sandbox Code Playgroud) 鉴于以下实体:
class DateTest(db.Model):
dateAdded = db.DateTimeProperty()
#...
Run Code Online (Sandbox Code Playgroud)
从本月获取记录的最佳方法是什么?
鉴于此json响应:
[
{
"diccioDatosForm": {
"errorMessage": "Verifique los datos invalidos ingresados...",
"encargadoLocalidad": "Ingrese un valor",
"responseStatus": "ERR",
"segundoNombre": "OK",
"encargadoProvincia": "Ingrese un valor"
}
},
{
"listaEncargados": []
}
]
Run Code Online (Sandbox Code Playgroud)
我需要访问键'diccioDatosForm'的元素.当我使用alert(alert(responseData))打印json时,我得到:
[object Object],[object Object]
Run Code Online (Sandbox Code Playgroud)
我试图这样做时没有得到任何东西:
alert(responseData.diccioDatosForm.errorMessage)
Run Code Online (Sandbox Code Playgroud)