如何在百万富翁的字符串中传递参数

时间:2017-07-12 16:31:45

标签: java spring-boot thymeleaf

我试图通过在百万富翁的href链接中传递任务ID来删除列表中的项目。这就是它的样子

<a th:href="@{'delete-task?id='${task.id}}"> 

但不是删除项目,而是输出

delete-task?id=th:text=%27${task.id}%27

我在松弛跟踪

中遇到此错误
 : Error parsing HTTP request header
 Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
Can anyone tell me the correct syntax

2 个答案:

答案 0 :(得分:2)

你应该使用百里香的Standard URL Syntax作为链接 - 以便参数可以正确地被网址转义。您的链接应如下所示:

import os
import sys,getopt
from impala.dbapi import connect

def main(argv):

    input = ''
    output = ''
    try:
      opts, args = getopt.getopt(argv,"hi:o:",["input=","output"])
    except getopt.GetOptError:
      print 'Usage append.py -i <input> -o <output>'
      sys.exit(2)
    for opt, arg in opts:
      if opt == '-h':
         print 'Usage append.py -i <input> -o <output>'
         sys.exit()
      elif opt in ("-i", "--input"):
         input = arg
      elif opt in ("-o", "--output"):
         output = arg
         print input


    conn = connect(host='hostname', port=port_number, auth_mechanism='GSSAPI', kerberos_service_name='impala', use_ssl=True)

    cursor = conn.cursor()

    sql = ('select empcode from empinfo where empcode in (select ecode from emptrav_det where ecode in({}))'.format(input))
    cursor.execute (sql)
    duplicate = cursor.fetchall()

    sql =('select ecode from emptrav_det where exp_c in({})'.format(input))
    print sql
    cursor.execute (sql)
    new = cursor.fetchall()
    if duplicate !=0:
       with open('output', 'a') as f:
          for emp in duplicate:
              f.write(str(emp[0]) + " " + ("Traveled\n"))

    if new ==0:
       with open('output', 'a') as f:
          for emp in new:
              f.write(str(emp[0]) + " " + ("Invalid ID\n"))

    conn.close()

if __name__ == '__main__':
    main(sys.argv[1:])

答案 1 :(得分:1)

我相信你的href看起来应该更像:

std::vector<int> foo(const std::vector<int>& v) {
  return v.filter([](int x) {return x > 5;})
          .map([](int x) {return x*x;})
          .sort();
}