我想使用Spring数据JPA获取随机记录.我正在使用@Query.但这需要很长时间.
@Query("select que from Question que order by RAND()")
public List<Question> findRandamQuestions();
Run Code Online (Sandbox Code Playgroud)
这样做的有效方法是哪种?请帮忙!
<c:if> 不用于比较字符.代码在表格内.这是代码
<c:if test="${record.type eq 'U' }">Planned</c:if>
Run Code Online (Sandbox Code Playgroud)
当我在表格中使用此代码时,表格内容不会显示.请帮忙!
我正在创建 Spring MVC web 应用程序。我的图像在我的 MVC 应用程序的文件夹 webapp/resources/img/logo.png 中。如何将图像从该文件夹加载到 pdf。
我尝试使用此代码。但它的 trowing java.io.FileNotFoundException。
String imageUrl = "webapp/resources/img/logo.png"
logo = Image.getInstance(imageUrl);
Run Code Online (Sandbox Code Playgroud) 我需要将带有时区的日期字符串解析为Dateobject.输入日期字符串模式为:
"MM/dd/yyyy hh:mm a z" (eg: 04/30/2018 06:00 PM IST).
Run Code Online (Sandbox Code Playgroud)
我使用下面给出的代码.但它返回错误的日期作为输出.
new SimpleDateFormat("MM/dd/yyyy hh:mm a z").parse("04/30/2018 06:00 PM IST")
Run Code Online (Sandbox Code Playgroud)
电流输出:"Mon Apr 30 09:00:00 PDT 2018".预期产出:"Mon Apr 30 05:30:00 PDT 2018.
我'与弹簧安置网络service.I'am无法工作转换JSON为Java Object使用@RequestBody.
控制器方法:
@RequestMapping(value="/test",method=RequestMethod.POST)
public @ResponseBody String test(@RequestBody Student s)
{
System.out.print(s.getName()+s.getMark()+s.getRollNo());
return "ok";
}
Run Code Online (Sandbox Code Playgroud)
POJO课程:
public class Student implements Serializable {
private static final long serialVersionUID = 1L;
private int mark;
private String name;
private int rollNo;
// getters and setters
}
Run Code Online (Sandbox Code Playgroud)
Serlvet-context.xml中的MessageConverter:
<beans:bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"></beans:bean>
<beans:bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<beans:property name="messageConverters">
<beans:list>
<beans:ref bean="jacksonMessageConverter"/>
</beans:list>
</beans:property>
</beans:bean>
Run Code Online (Sandbox Code Playgroud)
我正在使用POSTMANrest client chrome插件来调用webservice.JSON object传递的是:
{"mark":30,"name":"sam","rollNo":100}
Run Code Online (Sandbox Code Playgroud)
我415 Unsupported Media Type在调用Web服务时得到了响应.
请帮忙.提前致谢!