我有一个期望WebServiceRequest对象的通用Web服务.此对象具有Object类型的有效内容.以下是我的有效载荷的类型.
<xs:complexType name="payload">
<xs:sequence>
<xs:any processContents="lax"></xs:any>
</xs:sequence>
</xs:complexType>
Run Code Online (Sandbox Code Playgroud)
我JAXB为Web服务输入和输出类型创建了类.所以对于有效载荷,这是生成的字段.
@XmlAnyElement(lax = true)
private Object any;
Run Code Online (Sandbox Code Playgroud)
以下是我JAXB生成的WebServiceRequestVO 的结构.
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "serviceRequest", namespace = "http://ws.test.svc.com/", propOrder = {
"payload"
})
public class WebServiceRequest{
@XmlElement
private Payload payload;
}
public class Payload{
@XmlAnyElement(lax = true)
private Object any;
}
Run Code Online (Sandbox Code Playgroud)
我有一些自定义POJO,我需要填充并设置为有效负载.我使用以下注释注释了这些POJO
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class AddressVO {
@XmlElement
private String pinCode;
@XmlElement
private String city;
}
Run Code Online (Sandbox Code Playgroud)
我填充了此POJO的数据并尝试设置为有效负载WebServiceRequest.但是当我这样做时,我得到了以下异常.
javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: …Run Code Online (Sandbox Code Playgroud) 我有一个通过URL访问的servlet,该URL中有一些请求参数.现在我需要将用户重定向到另一个页面(来自servlet),还要附加我从请求中获取的请求参数.这就是我正在做的事情
StringBuffer sb=new StringBuffer("/test.jsp");
sb.append( "?" );
Enumeration en = request.getParameterNames();
while( en.hasMoreElements() ){
String paramName = (String) en.nextElement();
sb.append( paramName );
sb.append( "=" );
sb.append(request.getParameter( paramName ));
sb.append("&");
}
String constructedURLWithParams=sb.toString();
Run Code Online (Sandbox Code Playgroud)
但问题是,有一个"&"将被添加到构造的URL的末尾.我不想再做一些字符串操作并删除尾随的"&".你能建议一个更好的方法吗?
我需要加入Java中的两个列表.我有一个列表,其中有一个名称和描述的VO.我有另一个列表,它具有相同的VO类型,具有名称和地址."名字"是一样的.我需要创建一个包含此VO的List,它包含名称,地址和描述.VO结构是
public class PersonDetails{
private String name;
private String description;
private String address;
//getters and setters
}
Run Code Online (Sandbox Code Playgroud)
有人可以建议我实施它的最佳方法吗?
我正在研究JSF(v1.2)应用程序.在我的应用程序中,我需要一个可以为任何资源(PDF,图像,Excel等)提供服务的通用servlet.我的想法是让调用者发送所需的信息,以便我可以使用一些配置找出正确的委托者类.
此委托者类将负责提供正确的资源.
例如,这是请求网址
http://example.com/servlet?delegatorid=abcd
Run Code Online (Sandbox Code Playgroud)
我的Servlet代码是这样的.
protected void doGet(HttpServletRequest request, HttpServletResponse response){
String delegatorID=request.getParameter("delegatorid");
//Get the configuration from Configuration table
configuration=getConfiguration(delegatorID);
//invoke the method of the delegator class based on this configuration
Object result=invokeMethod(configuration);
//write the response to the stream
}
Run Code Online (Sandbox Code Playgroud)
我的问题是在JSF项目中执行此操作的最佳方法是什么?
你能告诉我你对此的看法吗?
我有两个Web应用程序,它们部署在同一个J2EE应用程序服务器中.我需要从一个Web应用程序重定向到另一个Web应用程序.此外,我需要在Web应用程序1的Header中设置一些信息,以便在Web应用程序2中可用.当我尝试访问Web App2中Web App1标题中设置的信息时,我得到"null" .我response.sendRedirect("http://localhost/webapp2")在Web应用程序1中使用重定向.请帮我解决这个问题.
谢谢,应用程序.
我有一个Javascript方法,它需要两个参数 - 第一个是应该执行的函数的名称,第二个是params数组,我需要传递给我需要执行的函数.基本上我需要使它成为通用函数.我可以使用Dojo以高效的方式实现这一目标吗?以下是我的功能.
function UserDetails(){
this.invokeCustomFunction=function(fnToBeExecuted,arraysOfParams){
//This function is expectetd to execute the "fnToBeExecuted" and pass the "arraysOfParams" to it.
}
this.getUserDetails=function(userName){
}
this.getSalaryDetails=function(userId,EmployerName){
}
}
//This is how I invoke it.
UserDetails userDetails=new UserDetails();
userDetails.invokeCustomFunction("getUserDetails","Sally");
userDetails.invokeCustomFunction("getSalaryDetails",["Sally","ATT"]);
Run Code Online (Sandbox Code Playgroud) 我知道有关于如何使用tcpdump的捕获网络通信,Wireshark的等等.我试图让多个线程-tcpdump emulator1.cap在Eclipse > Run Configurations.但我不知道这些数据的捕获位置.有人可以让我知道如何使用tcpdump捕获流量的分步说明吗?
我有一个像Java这样的界面
public interface Filter{
public boolean acceptData(IFilterData data);
}
public interface IFilterData{
}
Run Code Online (Sandbox Code Playgroud)
为什么Java不允许我拥有如下所示的实现类?
public class SampleFilterImpl{
public boolean acceptData(SampleFilterData data){
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
哪里 SampleFilterData implements IFilterData
我同意Filter接口指定的合同对吗?但是为什么它不允许我这样做的逻辑是什么?