首页 \ 问答 \ Spring MVC Samples中的“Hello World”来自哪里?(Where is the “Hello World” coming from in Spring MVC Samples)

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
更新时间:2023-03-27 07:03

最满意答案

使用

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 ...
  • 你为什么不“从用户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 ...
  • 看起来您的查询不是正确的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 ...
  • 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(); ...
  • 在查询方法上放置@Query注释,并使用命名查询的名称。 如下图所示。 @Query(name = "yourNamedQueryName") List exampleNamedQueryProjectedByOne(@Param("personId") Long personId); @Query(name = "yourNamedQueryName") List exampleNamedQueryProjectedBy ...
  • 使用 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.

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。