我有两个实体:
客户实体
@Entity
public class Customer {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
@OneToMany(mappedBy="customer", cascade=CascadeType.ALL)
private List<Facility> facilities;
//Setter and Getter for name and facilities
public void addFacility(Facility facility){
this.facilities.add(facility);
}
}
Run Code Online (Sandbox Code Playgroud)
设施实体
@Entity
public class Facility {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
@JoinColumn(name="CUSTOMER_FK")
private Customer customer;
private String name;
//Setter and Getter, equals and hashcode
...
}
Run Code Online (Sandbox Code Playgroud)
所以在我的主要内容中,我这样做
Customer customer = new Customer();
customer.setName("Wake Forest University");
Facility facility = new Facility();
facility.setName("Tom …Run Code Online (Sandbox Code Playgroud) 如果我的问题没有任何意义,我很抱歉.所以这就是我所拥有的:2页,A.jsf和B.jsf.当我按下一个按钮时A.jsf,代码设置一个值object并重定向到B.jsf.包含B.jsf将取决于我设置的对象A.jsf(这取决于我点击的按钮).因此,我不想让用户在Web浏览器上键入它
HTTP://为myhost:MyPort上/ myproject的/ B.jsf
并直接到达B.jsf.所以,没有GET请求B.jsf,只有POST.如果我看到GET请求B.jsf,我会重定向到A.jsf.我觉得解决方案就在里面web.xml.
顺便说一句,我使用的是Netbean 6.8和java EE 6
编辑
这是解决方案.感谢BalusC
MyFilter.java
package org.xdrawings.filter;
public class MyFilter implements Filter{
private FilterConfig filterConfig = null;
public void destroy(){}
public void init(FilterConfig filterConfig){
this.filterConfig = filterConfig;
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException{
HttpServletRequest req = (HttpServletRequest)request;
HttpServletResponse res = (HttpServletResponse) response;
if("GET".equals(req.getMethod()) …Run Code Online (Sandbox Code Playgroud) 整个语法如下
<h:commandLink action="CustomerDetails?faces-redirect=true&customerId=#{item.id}" value="#{item.name}"/>
Run Code Online (Sandbox Code Playgroud)
这是在dataTable中,因此解释了使用if item.但是上面的代码给了我
Not a Valid Method Expression: CustomerDetails?faces-redirect=true&customerId=#{item.id}
Run Code Online (Sandbox Code Playgroud)
它似乎不允许我连接字符串和EL表达式.做了很多内部value属性,必须是action属性的东西.有人为此得到了解决方案吗?
我有一张USER桌子,有桌子userId和point田地.在运行时,我想知道特定用户群的排名是什么.实现此目的的最佳方法是:
1:将所有用户查询到列表中.基于点对列表进行排序并进行二进制搜索以查找该用户的排名.这听起来像个坏主意.
2:是否可以通过创建数据库查询来完成这些任务?
我期待2000-5000用户.
编辑
我需要换www.myhost.com:8080/myproject-war到www.myhost.com.这是我一直在尝试的:
我说明了Virtual Server: server.我仍然有默认的网络侦听器是http-listener-1和http-listner-2.我将默认Web模块更改为ScholarActive#ScholarActive-war.war(下拉列表中的唯一选项,因为我只部署了1个应用程序).
对于docroot,我试试这个
${com.sun.aas.instanceRoot}/applications/ScholarActive/ScholarActive-war_war
Run Code Online (Sandbox Code Playgroud)
或这个
${com.sun.aas.instanceRoot}/applications/ScholarActive/
Run Code Online (Sandbox Code Playgroud)
两者都不起作用.docroot需要指出什么才能实现?
我尝试做的是:当我键入localhost:8080/ScholarActive-war,然后我的应用程序加载,我想这样做,如果我键入locahost:8080,它将加载应用程序,然后剩下的是改变了港口到80.但没有运气.任何的想法?
这个问题曾经在这里被问到过简单CRUD的EJB 3会话Bean设计,我只想更深入地询问有关此设计的问题.我已经尝试在原帖上提问,但是,我没有看到任何回复,所以我决定创建新帖子.因此,实现通用CRUD会话bean的Pascal解决方案如下
public interface GenericCrudService {
public <T> T create(T t);
public <T> T find(Class<T> type, Object id);
public <T> void delete(T t);
public <T> T update(T t);
public List findWithNamedQuery(String queryName);
public List findWithNamedQuery(String queryName, int resultLimit);
public List findWithNamedQuery(String namedQueryName,
Map<String, Object> parameters);
public List findWithNamedQuery(String namedQueryName,
Map<String, Object> parameters,
int resultLimit);
public <T> List<T> findWithNativeQuery(String sql, Class<T> type);
}
Run Code Online (Sandbox Code Playgroud)
和
@Stateless
@Remote(GenericCrudService.class)
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class GenericCrudServiceBean implements GenericCrudService {
@PersistenceContext
private EntityManager em;
@Override
public …Run Code Online (Sandbox Code Playgroud) 我想要的是:给定一个10页的pdf文件,我想在网络上的表格中显示该pdf的每个页面.实现这一目标的最佳方法是什么?我想一种方法是将这个10页的pdf文件分成10个1页的pdf,并以编程方式将每个pdf显示在一个表的一行上.我可以用iText这样做吗?有没有更好的方法来实现这一目标?
我有一个List,我想循环遍历该List并在某些条件下删除一些记录库.这就是我的工作
public void foo(List<Bar> recordList){
for(Bar bar : recordList){
if(bar.someCondition()){
recordList.remove(bar);
}
}
}
Run Code Online (Sandbox Code Playgroud)
此代码生成异常.如果我使用Iterator,那么它工作正常
public void foo(List<Bar> recordList){
Iterator<Bar> iter = recordList.iterator();
while(iter.hasNext()){
Bar bar = iter.next();
if(bar.someCondition()){
iter.remove();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我猜我的问题:
为什么第一段代码不起作用?
如何使第一段代码工作?
我需要将 pdf 中的每一页从字母大小调整为合法大小。这是我到目前为止所得到的
public void resize (float x, float y, float scale) throws Exception {
PdfReader reader = new PdfReader(pdfIn);
Document doc = new Document(PageSize.LEGAL, 0, 0, 0, 0);
PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(pdfOut));
doc.open();
PdfContentByte cb = writer.getDirectContent();
for(int i=1; i<=reader.getNumberOfPages(); i++){
PdfImportedPage page = writer.getImportedPage(reader, i);
cb.addTemplate(page, scale, 0, 0, scale, x, y);
}
doc.close();
}
Run Code Online (Sandbox Code Playgroud)
即使调整大小正确,输出 pdf 也只包含 1 页。请问有什么帮助吗?
我有一个包含跟随逻辑的表.
<tr class=hiderow><td class=packagename>...</td></tr>- >此行将不可见.因此表可能包含100行,但如果包含20行class=hiderow,则用户只能在页面上看到80行.我想检索那80行(不是100)的名称.所以我需要解析不包含的数据class=hiderow.我知道如何使用每个名字jsoup,我也看到文档中有,
:not(selector) elements that do not match the selector.但我不知道如何使用它.请帮忙.
编辑我已经弄清楚如何做到这一点.如果有更好的方法,请告诉我.
EDIT2请使用BalusC的以下解决方案.它更清洁.
public void obtainPackageName(String urlLink) throws IOException{
List<String> pdfList = new ArrayList<String>();
URL url = new URL(urlLink);
Document doc = Jsoup.parse(url, 3000);
Element table = doc.select("table[id=mastertableid]").first();
Iterator<Element> rowIter = table.select("tr").iterator();
while(rowIter.hasNext()){
Element row = rowIter.next();
if(!row.className().contains("hiderow")){
Element packageName = row.select("td[class=packagename]").first();
if(packageName != null){
pdfList.add(packageName.text());
}
}
}
}
Run Code Online (Sandbox Code Playgroud)