我有结果
Query query = session.createQuery("From Pool as p left join fetch p.poolQuestion as s");
Run Code Online (Sandbox Code Playgroud)
查询,我想在JSP上显示它.
我有循环:
<c:forEach items="${pools}" var="pool">
<p>${pool.name}</p>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)
我想显示poolQuestion表(连接表)的结果.我想要显示的值是"回答".
我该怎么做?
<c:forEach items="${pools}" var="pool">
<p>${pool.answer}</p>
<p>${pool.name}</p>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)
上面的代码不起作用.
错误是:
org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/views/home.jsp at line 21
18: <c:forEach items="${pools}" var="pool">
19:
20: <p>${pool.name}</p>
21: <c:out value="${pool.poolQuestion.answer}"/>
22:
23: </c:forEach>
24:
SEVERE: Servlet.service() for servlet appServlet threw exception
javax.el.PropertyNotFoundException: Property 'answer' not found on type com.pool.app.domain.Pool
at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:214)
at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:191)
at javax.el.BeanELResolver.property(BeanELResolver.java:300)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:81)
at …Run Code Online (Sandbox Code Playgroud) 我正在寻找设置hibernate或log4j来告诉我,在hibernate中执行查询需要多长时间,这些查询是由hql调用的.
直到现在我没有发现任何有趣的东西.
也许有些人可能会帮我解决这个问题?
我正在构建java应用程序,突然我发现编译问题:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project sonda: Compilation failure: Compilation failure:
[ERROR] ..../service/UserService.java:[7,23] package org.apache.log4j does not exist
Run Code Online (Sandbox Code Playgroud)
但我之前正在构建这个应用程序,一切都很好.另外,当我使用tomcat在Eclipse下运行这个应用程序时,它运行良好.
在pom我有:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
你能帮助我吗 ?
我需要发送一个HTTP cookie,我正在使用RestTemplate:
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.add("Cookie", "SERVERID=c52");
HttpEntity requestEntity = new HttpEntity(null, requestHeaders);
ResponseEntity responses = restTemplate.exchange(webService.getValidateUserUrl(),
HttpMethod.POST, requestEntity, String.class, mapValidateUser);
Run Code Online (Sandbox Code Playgroud)
但是,接收服务器看不到cookie.
我正在Spring中创建身份验证服务.
我正在使用UserDetailsService来获取表单变量,但我发现loadUserByUsername只有一个变量 - userName.
如何获取密码?
public class userAuthentication implements UserDetailsService{
private @Autowired
ASPWebServicesUtils aspWebServicesUtils;
@Override
public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException {
//how to get password ?
User user = new User("test", "test", true, true, true, true, getAuthorities(true));
return user;
}
private List<GrantedAuthority> getAuthorities(boolean isAdmin){
List<GrantedAuthority> authorityList = new ArrayList<GrantedAuthority>(2);
authorityList.add(new SimpleGrantedAuthority("USER_ROLE"));
if(isAdmin){
authorityList.add(new SimpleGrantedAuthority("ADMIN_ROLE"));
}
return authorityList;
}
//...
}
Run Code Online (Sandbox Code Playgroud)
谢谢
我创建了MVC应用程序.
我想将js或css文件包含到jsp中.
我的静态文件在:
- webapp
-js/jquery.js
-WEB-INF|
|
- jsp/*.jsp
我包含jquery的代码是:
<script type="text/javascript" src="<c:url value="js/jquery.js" />"></script>
Run Code Online (Sandbox Code Playgroud)
我无法将js文件加载到视图中.
我看到包含信息的日志:
WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/pool/js/jquery.js] in DispatcherServlet with name 'appServlet'
Run Code Online (Sandbox Code Playgroud)
是什么意思,MVC尝试将url映射到js文件.
我认为我的配置有一些东西,但我不知道是什么.
我的web.xml是:
<?xml version="1.0" encoding="UTF-8"?>
Run Code Online (Sandbox Code Playgroud)
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application …Run Code Online (Sandbox Code Playgroud) 我在代码中使用 JSONP:
<script>
$.ajax({
url:"http://localhost:8080/pool/main/?pool=abcd",
dataType: 'JSONP',
success:function(response){
$('#pool').append(response);
},
error:function(){
alert("ERROR");
},
});
</script>
Run Code Online (Sandbox Code Playgroud)
我必须使用 JSONP,因为我需要 ajax 跨域
在我的应用程序响应中,“ http://localhost:8080/pool/main/?pool=abcd” 是 HTML 代码。
我想在我的页面中显示此代码,但出现错误,因为我认为我无法返回 html。
错误 - 我的意思是 - 它为我生成了此代码error:function(){
alert("ERROR");
},但我在萤火虫中看到来自我的页面的响应http://localhost:8080/pool/main/?pool=abcd正常。但其次。我不知道如何将响应放入 html 元素。
我的问题是——我能还是不能。
如果我可以 - 如何做到这一点?
我想在我的网站上创建gmaps.
我找到了,如何获得坐标.
{
"results" : [
{
// body
"formatted_address" : "Pu?awska, Piaseczno, Polska",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 52.0979041,
"lng" : 21.0293984
},
"southwest" : {
"lat" : 52.0749265,
"lng" : 21.0145743
}
},
"location" : {
"lat" : 52.0860667,
"lng" : 21.0205308
},
"location_type" : "GEOMETRIC_CENTER",
"viewport" : {
"northeast" : {
"lat" : 52.0979041,
"lng" : 21.0293984
},
"southwest" : {
"lat" : 52.0749265,
"lng" : 21.0145743
}
}
},
"partial_match" …Run Code Online (Sandbox Code Playgroud) 我想问你两个Web服务之间发送数据(POST/GET变量)的最佳实践,它们之间是ESB:
WEB_SERVICE1 <-----------> ESB <----------> WEB_SERVICE2
我应该在ESB中创建另一个Web服务,它将在WEB_SERVICE1和WEB_SERVICE2之间传输数据吗?
我需要创建RestTemplate请求,它将通过PHP应用程序发送图像上传.
我的代码是:
Resource resource = new FileSystemResource("/Users/user/Documents/MG_0599.jpg");
MultiValueMap<String, Object> parts = new LinkedMultiValueMap<String, Object>();
parts.add("Content-Type", "image/jpeg");
parts.add("file", resource);
parts.add("id_product", productId);
ResponseEntity<String> response = cookieRestTemplate.getForEntity(url, String.class, parts);
Run Code Online (Sandbox Code Playgroud)
启动此应用程序后,PHP服务器向我发送信息,该文件为空.
我在想,这个问题是由PHP网站提供的,但是我已经为Firefox安装了POSTER插件,并且我在这个相同的URL上发出了GET请求,但是要上传的文件,我已经选择了像web表单中的那样(弹出系统窗口)选择文件).这个PHP程序上传文件后没有任何问题.
我想,问题可能在于,我将资源作为param名称的值发送:
parts.add("file", resource);
Run Code Online (Sandbox Code Playgroud)
在POSTER插件上,我只是从我的文件系统中选择文件?
你能帮助我吗 ?
我正在寻找教程或快速示例,我如何发送POST数据抛出openStream.
我的代码是:
URL url = new URL("http://localhost:8080/test");
InputStream response = url.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(response, "UTF-8"));
Run Code Online (Sandbox Code Playgroud)
你可以帮帮我吗 ?
我想使用NamedQueries计数表中的元素。
NamedQuery是:
@NamedQuery(name = Advertisement.countBySubcategoryList, query = "select count(*) from Advertisement where subcategoryId IN (:subcategoryId)")
Run Code Online (Sandbox Code Playgroud)
和:
public static final String countBySubcategoryList = "Advertisement.countBySubcategoryList";
Run Code Online (Sandbox Code Playgroud)
在模型中,我使用:
List<Advertisement> advertisements = session.getNamedQuery(Advertisement.countBySubcategoryList)
.setParameterList("subcategoryId", subcategoryIds)
.list();
Run Code Online (Sandbox Code Playgroud)
如何从查询中获取计数值?
我想创建某种 html 模板并将数据依次放入,如下所示:
<template>
<app-timeline>
<app-timeline-item
title="Goal Achieved"
subtitle="All milestones are completed"
time="few minutes ago"
variant="success"
>
<div>Nick</div>
</app-timeline-item
<app-timeline-item
title="Last milestone remain"
subtitle="You are just one step away from your goal"
time="3 minutes ago"
variant="info"
>
<div>Mark</div>
</app-timeline-item>
<app-timeline-item
title="Your are running low on time"
subtitle="Only 30 minutes left to finish milestone"
time="21 minutes ago"
variant="warning"
>
<div>Max</div>
</app-timeline-item>
<app-timeline-item
title="Client Meeting"
subtitle="New event has been added to your schedule"
time="36 minutes ago"
>
<div>Nico</div>
</app-timeline-item>
<app-timeline-item
title="Product Design" …Run Code Online (Sandbox Code Playgroud)