我已经共享了我的一部分代码,并且在“房间”类中,变量“nw”具有查询字符串值。现在,我希望 html 文件使用查询字符串值动态自动填充“nw”字段。我该怎么做明白了吗? self.get_namespaces 有帮助吗?
class Room(tornado.web.RequestHandler):
def get(self):
nw=self.get_argument("nw")
print(nw)
self.render("RoomPost.html")
class static(tornado.web.RequestHandler):
def get(self,key):
iname="static/" +key
print iname
self.render(iname)
settings = {
'debug': True,
'static_path': 'static'}
application = tornado.web.Application([
(r"/room",Room ),
#(r"/static/(.*)",static)
], **settings)
if __name__ == "__main__":
application.listen(5500)
tornado.ioloop.IOLoop.instance().start()
以下是html文件
<html>
<head>
<link rel="stylesheet" href="{{ static_url("css/registration.css")}} />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<c:import url="InnerHeader.js"></c:import>
<br><br><br>
<center>
<form action="/room" method="post" >
<fieldset>
<legend>
<b1>Room Add</b1>
</legend>
<table class="registerTable">
<tr>
<td>Name of NW/Name of Home</td>
<td><input type="text" name="nw" placeholder="Kfx-Home"
maxlength="15" size="30" autofocus required/></td>
</tr>
<tr>
<td colspan="2" align="center" >                
<input type="submit" value=" Submit " /></td>
</tr>
</table>
</fieldset>
</form>
</center>
以下链接帮助我找出答案:
我在龙卷风脚本中添加了 self.render("RoomPost.jsp",nw=nw) 并在 .jsp 脚本中添加了 autofocus required value="{{nw}}" readonly/>。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句