小编clu*_*s92的帖子

如何使用modelAttribute在ajax(jquery)中提交spring表单

我是Spring MVC的新手.我有这样的表格,

<form:form action="/myaction.htm" method="post" modelAttribute="myForm" id="formid"> 和一个返回json的控制器

public @ResponseBody ResultObject doPost(@ModelAttribute("myForm") MyForm myForm){ System.out.println("myform.input"); }

我可以使用提交$("#formid").submit();,我的modelAttribute工作正常,从UI获取值.

我的问题是,如何以jquery ajax方式提交此表单?我试过这个,

$.ajax({
type:"post",
url:"/myaction.htm",
async: false,
dataType: "json",
success: function(){
alert("success");
}

});
Run Code Online (Sandbox Code Playgroud)

提交表单但是modelAttribute值为空,如何在提交时包含modelAttribute对象(表单正在使用的对象)?

java jquery spring jsp

14
推荐指数
2
解决办法
4万
查看次数

如何使用 Airflow 解决 Postgres 连接的连接超时错误

当我运行气流 DAG 时,连接超时。当我早上运行它时,它每天都会发生。每次第一次尝试时,它都会发生在相同的任务步骤上。

\n
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection timed out\n    Is the server running on host \xe2\x80\x9chostname.domain.com\xe2\x80\x9d (99.999.999.99) and accepting\n    TCP/IP connections on port 77777?\n
Run Code Online (Sandbox Code Playgroud)\n

我检查了数据库连接,连接正常。我的数据库没有任何停机时间。

\n

我从您可以从气流 UI 获取的日志中复制了此错误。有谁知道这个错误的原因可能是什么?

\n

postgresql sqlalchemy psycopg2 airflow

5
推荐指数
0
解决办法
427
查看次数

如何仅查询具有表情符号的数据(postgresql)

我的数据包含数据库列中的表情符号,即

message_text
-------


Hi 
Run Code Online (Sandbox Code Playgroud)

我只想查询包含表情符号的数据的行。在 postgres 中是否有一种简单的方法可以做到这一点?

select data from table where data_col contains emoji
Run Code Online (Sandbox Code Playgroud)

目前我使用一个简单的查询

select message_text from cb_messages_v1 cmv
 where message_text IN ('','','','', '')
Run Code Online (Sandbox Code Playgroud)

但我希望它更具动态性,如果添加未来的情绪,它将捕获数据。

postgresql emoji

3
推荐指数
1
解决办法
313
查看次数

如何在 python 可调用中使用 postgres 连接 id 连接到 postgres

我正在使用 Airflow 的 python 运算符来调用 python 函数。错误发生在 try/ except 块中

def python_callable_new():
    print("Inside python callable ...")

    import psycopg2

    try:
        print("attempting database connection from python method.. ")
        conn = psycopg2.connect('postgres_defined_connection')
        print("success. ")
    except Exception as error:
        print("failed: ")
        print (error)
    return 'End of callable. '

    

with dag:
    start_task  = DummyOperator(  task_id= "start" )
    stop_task   = DummyOperator(  task_id= "stop"  )
    
    do_python_task = PythonOperator(
        task_id = 'do-py-operation',
        python_callable= python_callable_new,
    )

    extract_source_data = PostgresOperator(
        task_id='extract-cb-source-data',
        postgres_conn_id='postgres_defined_connection',
        sql='./sql_scripts/extract_csv_data.sql'
    )

    # csv_to_postgres

start_task >> do_python_task …
Run Code Online (Sandbox Code Playgroud)

python postgresql airflow

2
推荐指数
1
解决办法
5539
查看次数

Python 中冒号和等号的用法

class PrepareTableOperator(BaseOperator):
   def _load_table(self):
      drop_table_query: str = ( "drop table if exists " + self.get_table() )

Run Code Online (Sandbox Code Playgroud)

我是 python 的新手,但我确实有一点 Java 背景。我不明白的是 python 中冒号的用法。我用谷歌搜索了一下,它用于切片和启动函数定义。但上面没有“def”语法,所以对我来说这看起来不像一个函数。

我的问题是,Python中的冒号是什么,它是字典值的另一个赋值运算符,类似于键值对吗?这就是它在这里做的事吗?它本质上在这里做什么?

python python-3.x

0
推荐指数
1
解决办法
2617
查看次数

标签 统计

postgresql ×3

airflow ×2

python ×2

emoji ×1

java ×1

jquery ×1

jsp ×1

psycopg2 ×1

python-3.x ×1

spring ×1

sqlalchemy ×1