Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3309338
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:37:44+00:00 2026-05-17T21:37:44+00:00

in the controller params.max = Math.min(params?.max?.toInteger() ?: 10, 20) params.offset = params?.offset?.toInteger() ?: 0

  • 0

in the controller

 params.max = Math.min(params?.max?.toInteger() ?: 10, 20)
 params.offset = params?.offset?.toInteger() ?: 0

if you enter in the following urls

/books?offset=10&max=              //error
/books?offset=10&max=sdf          //error
/books?offset=&max=10            //works
/books?offset=adsfa&max=10      //error


java.lang.NumberFormatException: For input string: "asdf"

        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)

        at java.lang.Integer.parseInt(Integer.java:449)

        at java.lang.Integer.valueOf(Integer.java:554)

Is there a one line groovy answer to check against null/string characters in the url params?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:37:44+00:00Added an answer on May 17, 2026 at 9:37 pm

    Have a look at the Release Notes for Grails 1.2 where null safe converters for params and tag attributes were introduced.

    You should change your lines..

    params.max = Math.min(params?.max?.toInteger() ?: 10, 20)
    params.offset = params?.offset?.toInteger() ?: 0
    

    ..to the following code:

    params.max = Math.min(params.int('max') ?: 10, 20)
    params.offset = params.int('offset') ?: 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This works: Baseline Controller @search = Baseline.search(params[:search]) @baselines = @search.paginate :page => params[:page], :per_page
I have the following controller code: def create @admin = Admin.new(params[:admin]) respond_to do |format|
I have the following code in my controller: @video=Video.find(params[:id]) @video.increment!(:votes) respond_to do|format| format.js This
Given a controller method like: def show @model = Model.find(params[:id]) respond_to do |format| format.html
SORRY:: I forgot that params[:user_id] does not exist in the controller, using current_user.id !
In my view controller's -viewDidLoad method, I call [myTextField becomeFirstResponder]; This works like a
I often find myself writing this: params.delete(:controller) params.delete(:action) params.delete(:other_key) redirect_to my_path(params) The trail of
I was explaining to our SEO specialist that cakephp url structure is domain/controller/view/params so
My Controller class is decorated with an AuthorizeAttribute to protect the actions: [Authorize(Roles =
I want my controller to return the right HTTP response code when the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.