# Query Parameters
The query string is the part of a URL after the ? character. It is commonly used for search terms, pagination, or filtering. Actix Web handles query parameters via the web::Query extractor.
#Using web::Query
To extract query parameters, define a struct that derives Deserialize and represents the expected fields. Then, add web::Query<YourStruct> to your handler's parameters.
code_blocksrust
use actix_web::{web, HttpResponse};
use serde::Deserialize;
#[derive(Deserialize)]
struct Filter {
page: Option<u32>,
keyword: String,
}
async fn search(query: web::Query<Filter>) -> HttpResponse {
HttpResponse::Ok().body(format!("Searching for {} on page {:?}", query.keyword, query.page))
}#Optional Parameters
Always use Option<T> for query parameters that might not be present in the request. If you use a non-optional type and the parameter is missing, Actix Web will return a 400 Bad Request error.