小编use*_*206的帖子

即使存在,Hibernate也无法找到命名参数

Hibernate保持检测

org.hibernate.QueryParameterException: could not locate named parameter [name]
Run Code Online (Sandbox Code Playgroud)

即使它存在.这是我的hql

Query query = sess().createQuery("from UserProfile where firstName LIKE '%:name%'").setParameter("name", name);
Run Code Online (Sandbox Code Playgroud)

为什么hibernate不断抛出异常?即使参数存在?

java hibernate hql named-parameters

19
推荐指数
2
解决办法
4万
查看次数

getSource()和getActionCommand()

什么是getSource?它返回了什么?

什么是getActionCommand()以及它返回什么?

我对这两个人之间的困惑可以让任何人给予我或将它们区分给我吗?在UI中使用getSource和getActionCommand()有什么用?特别是TextField还是JTextField?

java user-interface swing action event-handling

18
推荐指数
2
解决办法
15万
查看次数

ElasticSearch仅返回具有不同值的文档

假设我有这个给定的数据

{
            "name" : "ABC",
            "favorite_cars" : [ "ferrari","toyota" ]
          }, {
            "name" : "ABC",
            "favorite_cars" : [ "ferrari","toyota" ]
          }, {
            "name" : "GEORGE",
            "favorite_cars" : [ "honda","Hyundae" ]
          }
Run Code Online (Sandbox Code Playgroud)

每当我在搜索最喜欢的汽车是丰田的人时查询这些数据,它就会返回这些数据

{

            "name" : "ABC",
            "favorite_cars" : [ "ferrari","toyota" ]
          }, {
            "name" : "ABC",
            "favorite_cars" : [ "ferrari","toyota" ]
          }
Run Code Online (Sandbox Code Playgroud)

结果是两个名称为ABC的记录.如何仅选择不同的文档?我想得到的结果只是这个

{
                "name" : "ABC",
                "favorite_cars" : [ "ferrari","toyota" ]
              }
Run Code Online (Sandbox Code Playgroud)

这是我的查询

{
    "fuzzy_like_this_field" : {
        "favorite_cars" : {
            "like_text" : "toyota",
            "max_query_terms" : 12
        }
    }
} …
Run Code Online (Sandbox Code Playgroud)

java aggregate nosql elasticsearch spring-data-elasticsearch

17
推荐指数
2
解决办法
2万
查看次数

有太多课程吗?

在开发时,您何时可以确定应用程序中是否包含许多不必要的类?你应该有多少课程有一定的限制?

oop design-patterns class

14
推荐指数
3
解决办法
6598
查看次数

Spring bean DTD和XMLNS

当我创建一个弹簧项目时,我总是遇到XLMNS的问题.什么是XMLNS?实际上这些是什么?

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
Run Code Online (Sandbox Code Playgroud)

我在哪里可以获得这些参考?(xmlns的资源:xsi和xsi:schemeLocation.)是否有这些在线手册?我似乎无法找到它们.

注意 当我说引用时,我指的是适合它们的URL

更新

我在哪里可以看到Spring bean,Spring Transactions,Spring MVC等的XML命名空间?及其架构位置?

java spring javabeans

14
推荐指数
1
解决办法
2万
查看次数

从@ElementCollection中搜索对象

我正在使用Spring Data JPA.

我是这样的实体

public class A {

    @CollectionTable(name = "B_ITEMS", joinColumns = @JoinColumn(name = "B_ID"))
    @ElementCollection
    private List<B> bs;

}
Run Code Online (Sandbox Code Playgroud)

和嵌入式课程

@Embeddable
public class B { 

private String prop1


private String prop2


private String prop3

}
Run Code Online (Sandbox Code Playgroud)

如何使用内容@ElementCollection B搜索实体A?

这是我的存储库Spring Data JPA Repositry

public interface ARepo extends PagingAndSortingRepository<Clinic, Long> {

}
Run Code Online (Sandbox Code Playgroud)

什么查询方法名称适用于我的用例?

java spring jpa spring-data-jpa

14
推荐指数
1
解决办法
2275
查看次数

JSP处理指令未关闭

我试图在我的JSP中包含一个HTML文件,但是eclipse显示了这个错误

包含的文件

<%@include file="includes/head.html" %>
Run Code Online (Sandbox Code Playgroud)

而错误

Processing instruction not closed
Run Code Online (Sandbox Code Playgroud)

这只是简单的JSP

<%@include file = "includes/head.html" %>

    <form action = "#" method = "POST">
        Username: <input type = "text" name = "username"><br/>
        Password: <input type = "password" name = "password"><br/>
    </form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

jsp jspinclude include java-ee

13
推荐指数
3
解决办法
2万
查看次数

没有找到带有URI Spring MVC的HTTP请求的映射

这是我的Web.xml

dispatcherServlet org.springframework.web.servlet.DispatcherServlet contextConfigLocation /WEB-INF/spring/servlet-context.xml 1

<servlet>
    <servlet-name>dispatcherServlet</servlet-name>
    <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/spring/servlet-context.xml
        </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>dispatcherServlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>
Run Code Online (Sandbox Code Playgroud)

我的servlet-context.xml

<context:component-scan base-package="com.springexample.controller.impl" />
    <mvc:annotation-driven />

    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/views/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>
Run Code Online (Sandbox Code Playgroud)

最后是Handler类.它位于com.springexample.controller.impl下

@Controller
public class IndexControllerImpl implements IndexController {

    @RequestMapping("/")
    public String index() {

        return "index";
    }
}
Run Code Online (Sandbox Code Playgroud)

但是要去 localhost:8080/projectname/

它返回404错误.

Jul 27, 2013 8:18:31 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with …
Run Code Online (Sandbox Code Playgroud)

java model-view-controller spring spring-mvc

13
推荐指数
1
解决办法
11万
查看次数

Spring框架:在locale代码下找不到任何消息

这是我的messageResource声明

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <!-- Auto-detect controllers in this package -->
    <context:component-scan base-package="levelup.world.web" />

    <!-- Prepend /WEB-INF/jsp/ and append .jsp to the view name -->
    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <!-- Access resource bundles with the specified basename -->
    <bean id="messageSource"
        class="org.springframework.context.support.ReloadableResourceBundleMessageSource"
        p:basename="/WEB-INF/messages/" />

</beans>
Run Code Online (Sandbox Code Playgroud)

当我运行我的应用程序时,会出现此错误

No message found under code 'country.plural' for locale 'fil_PH'
Run Code Online (Sandbox Code Playgroud)

现在在web-inf里面的我的消息文件夹里面,我有以下消息属性

messages_en.properties
messages_fr.properties
messages.properties
Run Code Online (Sandbox Code Playgroud)

我在这里失踪了什么?

spring message spring-mvc

12
推荐指数
3
解决办法
7万
查看次数

Spring Data仅使用Date查询DateTime

我有这个数据模型

public class CustomerModel{

  @Column
  @Type(type="org.joda.time.contrib.hibernate.PersistentDateTime")
  private DateTime membershipDate;
  //Other properties and getters
}
Run Code Online (Sandbox Code Playgroud)

以下回购

public interface CustomerRepo  extends Repository<CustomerModel, Long>{}
Run Code Online (Sandbox Code Playgroud)

我想做的是.检索给定日期的所有用户,例如(2013年8月1日加入的成员)但问题是我的数据库上的membershipDate有时间.如何忽略时间并检索给定日期的所有用户?

java spring jpa spring-data spring-data-jpa

12
推荐指数
2
解决办法
5万
查看次数