【问题标题】:Finders in Spring Roo Fail to WorkSpring Roo 中的查找器无法正常工作
【发布时间】:2016-01-10 11:25:58
【问题描述】:

我正在慢慢尝试学习 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)
);

我的 roo 脚本如下:

// 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 

之后我启动应用程序。单击按人口查找城市的链接时,我收到前面提到的错误,有人可以帮忙吗?甚至不确定从哪里开始调试...

【问题讨论】:

  • 您能否提供更多关于您如何运行生成的应用程序的信息? Tomcat Maven 插件使用mvn tomcat:runmvn tomcat7:run?来自 STS 的 Tomcat 服务器? JBoss 服务器?哪个版本?
  • 感谢您的回复。我正在使用 STS 的 Tomcat 7 服务器。即使我遵循 [tutorial][(ttps://github.com/DISID/gvnix-samples/tree/master/quickstart-app#create-patterns-and-details-using-datatables) 字词,我也会收到此错误字,查找器链接都不起作用,数据表中的编辑和删除功能也不起作用(网址变为http://localhost:8080/petclinic/owners/'+full.id+'?form&amp...,而不是作为参数传递的行索引,而是传递'+full.id'
  • 好的,我们知道您的问题的解决方案。几分钟后,我们将使用提供的解决方案发布答案​​。请验证答案是否适合您。问候。

标签: spring-roo gvnix


【解决方案1】:

默认情况下,STS 下载 tomcat 7.0.47 版本,该版本有一个错误编码正确地在 Spring Requests 中使用的 URL。如果您在发送请求时查看 URL,您将看到 & 而不是每个参数的简单 &,这会导致请求不适合正确的 @RequestParam 方法。

更改 Tomcat 7 版本应该可以解决这个问题。您可以从here 下载它。解压到新文件夹,从STS添加为tomcat7服务器,无需下载(STS下载默认7.0.47版本)。尝试使用该新服务器运行应用程序。这也应该可以解决您在数据表视图中编辑和删除行的问题。

希望对您有所帮助。请评论并验证它是否有效。

【讨论】:

  • 感谢 Tumaini 对 gvNIX 项目的支持。
猜你喜欢
  • 1970-01-01
  • 2018-10-29
  • 2017-04-29
  • 1970-01-01
  • 1970-01-01
  • 2021-11-02
  • 2017-08-13
  • 2020-02-09
  • 2021-09-20
相关资源
最近更新 更多