Spring MVC Samples中的“Hello World”来自哪里?(Where is the “Hello World” coming from in Spring MVC Samples)
我试图从git中查看Spring Show Case中的代码
https://github.com/SpringSource/spring-mvc-showcase
但是如果你点击简单的链接,我会在第一页上遗漏一些东西,你会得到绿色的“Hello World”。
所以我查看了JSP页面,发现了这段代码:
<ul> <li> <a id="simpleLink" class="textLink" href="<c:url value="/simple" />">GET /simple</a> </li> <li> <a id="simpleRevisited" class="textLink" href="<c:url value="/simple/revisited" />">GET /simple/revisited</a> </li> </ul>
对控制器的调用在哪里,但我没有看到JSP页面如何知道将“Hello World”置于绿色的位置。
然后我审查了控件,我发现:
@Controller public class SimpleController { @RequestMapping("/simple") public @ResponseBody String simple() { return "Hello world!"; } }
其中“Hello World”出现在JSP中,但JSP如何知道放在哪里? 我看不到任何标签
I am trying to review the code in Spring Show Case from git
https://github.com/SpringSource/spring-mvc-showcase
But I am missing something on the first page if you click on the simple link you get back "Hello World" in green.
So I looked in the JSP page and I found this code:
<ul> <li> <a id="simpleLink" class="textLink" href="<c:url value="/simple" />">GET /simple</a> </li> <li> <a id="simpleRevisited" class="textLink" href="<c:url value="/simple/revisited" />">GET /simple/revisited</a> </li> </ul>
Where does the call to the contoller but I dont see how the JSP page knows where to put the "Hello World" in green.
I then reviewed the control and I found:
@Controller public class SimpleController { @RequestMapping("/simple") public @ResponseBody String simple() { return "Hello world!"; } }
Which sents the "Hello World" out to the JSP but how does the JSP know where to put it? I dont see any tag
原文:https://stackoverflow.com/questions/15272325
最满意答案
使用
SELECT x FROM Payment x WHERE x.amount > (SELECT AVG(p.amount) from Payment p)
你的子查询是
SELECT AVG(x.amount) from Payment
,
x
未定义。Use
SELECT x FROM Payment x WHERE x.amount > (SELECT AVG(p.amount) from Payment p)
Your subquery is
SELECT AVG(x.amount) from Payment
, and
x
is not defined.
相关问答
更多-
根据JPA 2.1(JavaEE 7),您的查询是正确的JPQL。 如果他们支持2.1版本的JPA,Eclipselink也支持它和其他提供者。 使用JOIN的操作员ON是最新的JPA版本,它既不存在于JPA 2.0(JavaEE 6)中,也不存在于较旧的JPA 1版本中。 以下是EclipseLink wiki的更多信息。 维基表示Eclipselink实现了ON运算符,并且它在JPA 2.1草案中。 我还检查了它也是最终的JPA 2.1规范 - 它就在那里。 为了使用您的查询,您只需要确保您的环境/应用 ...
-
您的实体代码是自动生成的吗? 也许您应该尝试更新生成的实体代码。 将myDate字段的类型更改为Date而不是java.sql.Timestamp 。 然后使用@Temporal注释它并指定DATE作为类型,如下面的代码所示: @Column(name="MY_DATE") @Temporal(TemporalType.DATE) private Date myDate; 在您的查询中,您可以使用BETWEEN而不是比较运算符: o.myDate BETWEEN :startDate AND :endDa ...
-
JPA命名查询连接(JPA Named query join)[2023-01-12]
你为什么不“从用户u中选择你的u.id =:id”并在你的java代码中通过u.getFollowers()访问关注者? 如果您的实体具有关系,则不明确需要连接。 Why don't you do "select u from User u where u.id = :id" and access the followers via u.getFollowers() in your java code? You don't explicitly need the join if your entities ... -
JPA命名查询显示错误(JPA Named Query showing error)[2022-09-15]
看起来您的查询不是正确的JPQL语法,因为JPA中没有acos , pi , sin , cod函数,您的查询看起来像本地查询,为了解决您的问题,您有两种选择: 第一个选项:将您的查询转换为正确的JPQL语法,您可以按照文档 第二个选项:使用nativeQuery = true属性@Query(nativeQuery = true, value="SELECT * FROM(...") ,注意*在查询中没有别名c 。 您可以使用 : @Query(value = "SELECT * FROM(SELECT ... -
如果您确实需要,您可以始终通过JPA访问特定于提供者的类unwrap()在JPA 2.0中使用unwrap()或在以前版本中使用向下转换): String s = em.createNamedQuery("...") .unwrap(org.hibernate.Query.class) .getQueryString(); If you actually need, you can always access provider-specific classes via JPA (with ...
-
这是如何处理这个问题,你应该使用Stream API。 List
listEntity = yourservicenameTogetDataFromDataBase(); //grouping By id_client Map > groupingMap = listEntity .stream() .collect(Collectors.groupingBy(o->o.getIdClient())); //result ... -
如何在Spring数据JPA中使用XML配置进行命名查询?(How to use XML configuration for named queries in Spring data JPA?)[2022-08-05]
say you have defined the `Named Query` as `application.myquery` in XML file. 在service / dao层 List results = em.createNamedQuery("application.myquery") .setParameter("username", "blah") .setParameter("password","blahblahblah") .getResultList(); ... -
如何在Spring数据JPA中的多个查询方法中重用命名查询?(How to reuse named query in multiple query methods in Spring data JPA?)[2023-05-14]
在查询方法上放置@Query注释,并使用命名查询的名称。 如下图所示。 @Query(name = "yourNamedQueryName") ListexampleNamedQueryProjectedByOne(@Param("personId") Long personId); @Query(name = "yourNamedQueryName") List exampleNamedQueryProjectedBy ... -
JPA命名查询(JPA Named query)[2022-09-05]
使用 SELECT x FROM Payment x WHERE x.amount > (SELECT AVG(p.amount) from Payment p) 你的子查询是 SELECT AVG(x.amount) from Payment , x未定义。 Use SELECT x FROM Payment x WHERE x.amount > (SELECT AVG(p.amount) from Payment p) Your subquery is SELECT AVG(x.amount) ... -
调用getResultList()时,将执行所有查询,无论是否命名。 正如javadoc所说: 执行SELECT查询并将查询结果作为无类型列表返回。 All queries, named or not, are executed when you call getResultList(). Just as the javadoc says: Execute a SELECT query and return the query results as an untyped List.