我正面临一个问题,即在后端使用jax-rs进行角度调整.crud非常简单,有些文本字段和图像字段.
我有代码工作上传图像:
@POST
@Consumes("multipart/form-data")
public Response uploadFile(MultipartFormDataInput input) {
...
}
Run Code Online (Sandbox Code Playgroud)
并在html层:
<form action="http://localhost:8080/app/api/user" method="post" enctype="multipart/form-data">
<p>
Choose a file : <input type="file" name="file" />
</p>
<input type="submit" value="Upload" />
</form>
Run Code Online (Sandbox Code Playgroud)
所以,我的问题是如何在这一步中做到这一点:
@POST
@Consumes("multipart/form-data")
public Response save(MultipartFormDataInput input, MyEntity entity) {
...
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试从视图层调用上面的代码,那么wildfly会给出一个错误,该错误没有找到要与MyEntity参数绑定的数据.
[org.jboss.resteasy.core.ExceptionHandler] (default task-3) failed to execute: javax.ws.rs.NotSupportedException:
Could not find message body reader for type: class mypackage.MyEntity of content type: multipart/form-data;boundary=----WebKitFormBoundaryRXVvqLpZACPylNgS
Run Code Online (Sandbox Code Playgroud)
有谁知道我该怎么做?或者说我分两步走了吗?
我做错了什么吗?
import java.util.Date;
import java.util.Timer;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.LocalBean;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.ejb.Timeout;
import javax.ejb.TimerService;
@Singleton
@LocalBean
@Startup
public class CIScheduler {
@Resource
private TimerService timerService;
@PostConstruct
public void init() {
timerService.createTimer(1000, 5000, "myTimerInterval");
}
@Timeout
public void execute(Timer timer) {
System.out.println("Current Time : " + new Date());
}
}
Run Code Online (Sandbox Code Playgroud)
堆栈:JDK 8、Wildfly 10
错误日志:
09:31:31,781 警告 [org.jboss.as.ejb3](EJB 默认值 - 9)WFLYEJB0161:无法恢复计时器“config-api.config-api.CIScheduler”(id=f571b03a-efa 9-467d-a9de- b17d88bf54c7)从其持久状态09:31:31,783错误[org.jboss.as.ejb3](EJB默认 - 9)WFLYEJB0022:重试计时器超时期间出错:[id = 35f55f82-a982-43d8-bece-42cfc89debe8 timedObj ectId=config-api.config-api.CIScheduler 自动定时器?:假持久?:真timerService=org.jboss.as.ejb3.timerservice.TimerServiceImpl@1eef0fd init ialExpiration=Wed Jun 15 09:20:46 BRT 2016 …
我需要可以独立检查父节点和子节点.例如,如果我的树有一个带子节点,那么comportment是:
如果我检查这个孩子,也会自动检查父母,反之亦然.我想检查一个孩子或父母,不要改变另一个.
我怎样才能"删除"这两者的依赖?
任何帮助表示赞赏.
谢谢提前!
当标签更改时,如何避免再循环视图重新加载?例如,我有一个带有三个Tabs的TabLayout,我的ViewPager是:
class ViewPagerAdapter extends FragmentPagerAdapter {
public ViewPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return new Tab1Fragment();
case 1:
return new Tab2Fragment();
case 2:
return new Tab3Fragment();
}
return null;
}
@Override
public int getCount() {
return 3;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "tab1";
case 1:
return "tab2";
case 2:
return "tab3";
}
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
在第一个,我有一个recyclerview,当我更改选项卡并返回到第一个时,重新加载列表.有办法避免这种重装吗?只需保持数据加载.
有没有办法通过按Android设备上的后退按钮关闭游戏?
我无法让它发挥作用.