简体   繁体   中英

Finders in Spring Roo Fail to Work

I am slowly trying to learn Spring Roo but have come unstuck when generating finders for my application. The resulting menu when rendered on the browser shows the existence of the finder (a link), but on clicking the link, I immediately get the error

 HTTP Status 400 - Required Integer parameter 'population' is not present

type Status report

message Required Integer parameter 'population' is not present

description The request sent by the client was syntactically incorrect.

I have tried with both gvNIX 1.4.0.RELEASE - Roo 1.3.1.RELEASE [rev 8cb81a3] and with plain Roo 1.3.1.RC1 (no gvnix addon).

From the database end am using postgres 9.3. My database scripts to recreate the problem:

CREATE DATABASE world;    

CREATE TABLE city
(
  id integer NOT NULL,
  name text NOT NULL,
  countrycode character(3) NOT NULL,
  district text NOT NULL,
  population integer NOT NULL,
  CONSTRAINT city_pkey PRIMARY KEY (id)
);

CREATE TABLE country
(
  id integer NOT NULL DEFAULT nextval('hibernate_sequence'::regclass),
  code character(3) NOT NULL,
  name text NOT NULL,
  continent text NOT NULL,
  region text NOT NULL,
  surfacearea real NOT NULL,
  indepyear smallint,
  population integer NOT NULL,
  lifeexpectancy real,
  gnp numeric(10,2),
  gnpold numeric(10,2),
  localname text NOT NULL,
  governmentform text NOT NULL,
  headofstate text,
  capital integer,
  code2 character(2) NOT NULL,
  CONSTRAINT country_pkey PRIMARY KEY (id),
  CONSTRAINT country_continent_check CHECK (continent = 'Asia'::text OR continent = 'Europe'::text OR continent = 'North America'::text OR continent = 'Africa'::text OR continent = 'Oceania'::text OR continent = 'Antarctica'::text OR continent = 'South America'::text)
);

CREATE TABLE countrylanguage
(
  countrycode character(3) NOT NULL,
  language text NOT NULL,
  isofficial boolean NOT NULL,
  percentage real NOT NULL,
  CONSTRAINT countrylanguage_pkey PRIMARY KEY (countrycode, language)
);

My roo scripts are as follws:

// Spring Roo 1.3.1.RELEASE [rev 8cb81a3] log opened at 2016-01-10 14:01:09
project --topLevelPackage org.world --projectName world --java 7 --packaging JAR
// Spring Roo 1.3.1.RELEASE [rev 8cb81a3] log closed at 2016-01-10 14:01:11
// Spring Roo 1.3.1.RELEASE [rev 8cb81a3] log opened at 2016-01-10 14:08:38
jpa setup --database POSTGRES --provider HIBERNATE --databaseName world --hostName localhost --userName postgres --password postgres
database introspect --schema public
database reverse engineer --schema public --package ~.domain
focus --class ~.domain.City
finder list
finder add --finderName findCitysByPopulationLessThan
web mvc setup
web mvc all --package ~.web
web mvc finder all 

After which I launch the application. On clicking the link for finding citys by population , I get the error mentioned earlier, can anyone assist? Am not even sure where to begin debugging...

By default STS donwloads tomcat 7.0.47 version, which has a bug encoding correctly the URL's used in Spring Requests. If you look at the URL when sending the request you'll see & instead of simple & for each parameter, which causes that the request can't fit the right @RequestParam method.

Changing Tomcat 7 version should fix that. You can donwload it from here . Unzip it in a new folder and add it from STS as tomcat7 server without downloading it (STS downloads default 7.0.47 version). Try to run the app with that new server. That should fix as well your problem with editing and deleting rows in datatables views.

Hope it helps. Please, comment and validate if it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM