How do I prevent SQL injection with ColdFusion
问题 How do I prevent SQL injection when it comes to ColdFusion? I'm quite new to the language/framework. Here is my example query. <cfquery name="rsRecord" datasource="DataSource"> SELECT * FROM Table WHERE id = #url.id# </cfquery> I see passing in url.id as a risk. 回答1: Use a <cfqueryparam> tag for your id: http://www.adobe.com/livedocs/coldfusion/6.1/htmldocs/tags-b20.htm <cfquery name="rsRecord" datasource="DataSource"> SELECT * FROM Table WHERE id = <cfqueryparam value = "#url.id#" CFSQLType