2016-01-10 25 views
1

我正在慢慢地嘗試學習Spring Roo,但在爲我的應用程序生成查找程序時,它們已經開始鬆動。當在瀏覽器中呈現生成的菜單顯示取景器(鏈接)的存在,但是點擊鏈接,我立刻得到錯誤Spring Roo中的查找程序無法正常工作

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. 

我有兩個gvNIX 1.4.0.RELEASE - Roo 1.3.1.RELEASE [rev 8cb81a3],並用普通Roo 1.3.1.RC1(無gvnix嘗試加上)。

從數據庫結束我使用postgres 9.3。我的數據庫腳本來重現問題:

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) 
); 

我的袋鼠腳本如下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 

後,我啓動應用程序。點擊人口查找城市的鏈接,我得到前面提到的錯誤,任何人都可以協助?我甚至不知道從哪裏開始調試......

+0

您能否提供更多關於如何運行生成的應用程序的信息? Tomcat Maven插件使用'mvn tomcat:run'或'mvn tomcat7:run'? STS的Tomcat服務器? JBoss服務器?他們的哪個版本? – jcgarcia

+0

感謝您的回覆。我使用STS的Tomcat 7服務器。即使我按照[教程] [(ttps://github.com/DISID/gvnix-samples/tree/master/quickstart-app#create-patterns-and-details-using-datatables))字樣,我也會收到此錯誤單詞,這兩個finder鏈接都不起作用,並且數據表中的編輯和刪除功能不起作用(URL變爲'http:// localhost:8080/petclinic/owners /'+ full.id +'?form&' ,而不是作爲參數傳遞的行索引,而是傳遞''+ full.id'' –

+0

好的,我們知道您的問題的解決方案。幾分鐘後,我們將發佈一個答案與提供的解決方案。請,驗證答案,如果它適合你。關心。 – jcgarcia

回答

3

默認情況下,STS不下載tomcat 7.0.47版本,該版本有一個編碼正確的用於Spring Requests的URL。如果您在發送請求時查看網址,則會看到每個參數爲&,而不是簡單的&,這會導致請求無法符合正確的@RequestParam方法。

更改Tomcat 7版本應該可以解決這個問題。你可以從here上下載它。將其解壓縮到一個新文件夾中,並將其作爲tomcat7服務器從STS中添加,而無需下載它(STS下載默認的7.0.47版本)。嘗試使用該新服務器運行應用程序。這應該可以解決您在編輯和刪除數據表視圖中的行時遇到的問題。

希望它有幫助。請評論並驗證它是否有效。

+0

謝謝,多數民衆贊成工作出色! –

+0

感謝Tumaini支持gvNIX項目。 – jcgarcia