我想使用域名指向本地服务器IP地址上的网页.但是,问题是页面链接到在端口8088上设置的IP地址而不是80,因为后者已被另一个网页使用.通过域名公司我被告知他们不能这样做,因为域名只能指向端口80上设置的IP地址.所以现在我陷入了僵局.我有什么替代方案,如何建立一个指向IP的域名:8088?
谢谢
我尝试使用以下控制器
@RequestMapping(value="actions.htm", params="reqType=delete",method=RequestMethod.POST)
@ResponseBody
public String deletePendingAction(@RequestParam("aPk") Long aPk)
{
pendingActionsService.deletePendingAction(aPk);
return "Deleted";
}
Run Code Online (Sandbox Code Playgroud)
我使用params ="reqType = delete"这就是我认为junit无法映射到控制器的原因.我测试了所有其他控制器,它们工作正常,没有params标签到控制器.我的junit配置是:
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(classes = ApplicationConfig.class,loader = AnnotationConfigWebContextLoader.class)
@TransactionConfiguration(defaultRollback = true)
@Transactional
public class JUnitTests {
@Autowired
private WebApplicationContext wac;
private MockMvc mockMvc;
@Before
public void SetupContext()
{
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
}
@Test
public void testController() throws Exception
{
this.mockMvc.perform(post("/actions.htm","reqType=delete").param("aPk","2"));
}
}
Run Code Online (Sandbox Code Playgroud)
如何将此params标签翻译为spring mvc junit?谢谢
我有一个带有构造函数参数的 bean,我想使用注释将其自动装配到另一个 bean 中。如果我在主配置中定义 bean 并在那里传递构造函数参数,那么它工作正常。但是,我没有主要配置,而是使用@Componentwith@ComponentScan来注册 bean。我试过使用@Value属性来定义参数,但后来出现异常 No default constructor found;
@Component
public class Bean {
private String a;
private String b;
public Bean(@Value("a") String a, @Value("b") String b)
{
this.a = a;
this.b = b;
}
public void print()
{
System.out.println("printing");
}
}
@Component
public class SecondBean {
private Bean bean;
@Autowired
public SecondBean(Bean bean)
{
this.bean = bean;
}
public void callPrint()
{
bean.print();
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用下面的cloudoformation模板创建RDS集群和极光实例:
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "example setup",
"Parameters" : {
"DBInstanceIdentifier" : {
"Type": "String",
"Description": "Name for the DB instance."
},
"DBUser" : {
"Type": "String",
"Description": "Master user"
},
"DBPassword" : {
"Type": "String",
"Description": "Pass"
},
"DBModel" : {
"Type": "String",
"Description": "Instance model to be used for the DB."
}
},
"Resources": {
"RDSCluster": {
"Type": "AWS::RDS::DBCluster",
"Properties": {
"MasterUsername": { "Ref" : "DBUser" },
"MasterUserPassword": { "Ref" : "DBPassword" },
"Engine": "aurora",
"DBClusterParameterGroupName": …Run Code Online (Sandbox Code Playgroud) amazon-web-services amazon-rds aws-cloudformation amazon-aurora
我有一个Ajax调用来从Hibernate Objects填充前端的多个字段.这就是为什么我想从Spring返回多个Java Hibernate到Json序列化对象到Ajax.目前我这样做:
@RequestMapping(method=RequestMethod.GET)
@ResponseBody
public String getJson()
{
List<TableObject> result = serviceTableObject.getTableObject(pk);
String json = "";
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
try
{
json = ow.writeValueAsString(result);
} catch (JsonGenerationException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return json;
}
Run Code Online (Sandbox Code Playgroud)
这工作正常并返回一个json对象到ajax但我有多个这样的对象所以我想要的是将所有这些对象嵌套在一个json对象中并将后者返回到我的ajax,这样我就可以使用一个对象填充所有字段而不是制作多个ajax调用我需要的每个对象.所以例如我会有类似的东西:
List<TableObject> result = serviceTableObject.getTableObject(pk);
String json = "";
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
json = …Run Code Online (Sandbox Code Playgroud) 我在表中有一列包含xml类型的数据,但是采用varchar格式.一个示例原始数据是:
<old_template_code>BEVA30D</old_template_code><old_template_name>Beva
30D France calls capped
15p</old_template_name><new_template_code>BEVA24M</new_template_code><new_template_name>Beva 24M France Calls Capped 15p</new_template_name>
Run Code Online (Sandbox Code Playgroud)
我想知道我必须使用什么正则表达式来检索例如'BEVA30D' <old_template_code>?
我试过了
REGEXP_SUBSTR(table.column,
'<old_template_code>*</old_template_code>') "REGEXPR_SUBSTR"
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
目前,我需要将一个大的json对象发送到ajax请求.为此我使用以下控制器方法,它工作正常.
@RequestMapping(method = RequestMethod.POST,params = {"dynamicScenario"})
@ResponseBody
public String getDynamicScenarioData(@RequestParam Map<String, String> map) throws JsonParseException, JsonMappingException, IOException
{
ObjectMapper mapper = new ObjectMapper();
@SuppressWarnings("unchecked")
Map<String,Object> queryParameters = mapper.readValue(map.get("parameters") , Map.class);
Map<String, Object> getData = service.runDynamicScenario(queryParameters, map.get("queryString"));
return writer.writeValueAsString(getData); //here java throws java.lang.OutOfMemoryError: Java heap space memory
}
Run Code Online (Sandbox Code Playgroud)
更新:我的ajax是:
$.ajax({
type: "POST",
url: "dynamicScenario.htm",
data : tags,
dataType: "json",
success: function(data){});
Run Code Online (Sandbox Code Playgroud)
我的DispatcherServlet设置:
public class ApplicationInitializer implements WebApplicationInitializer
{
public void onStartup(ServletContext servletContext) throws
ServletException
{
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.register(ApplicationConfig.class); …Run Code Online (Sandbox Code Playgroud) 我试图通过点击它来检索char x轴上的标签文本.我正在使用条形图,代码如下:
var chart = new Highcharts.Chart({
chart: {
type: 'column',
backgroundColor: '#eaedf1',
zoomType: 'x',
renderTo: 'container'
},
plotOptions: {
series: {
cursor: 'pointer',
pointWidth: 10,
point: {
events: {
click: function (event) {
console.log(event.point.name + " " + this.y);
}
}
}
}
},
title: {
text: 'Total Flow Types'
},
xAxis: {
type: 'category',
labels: {
rotation: -90
}
},
yAxis: {
min: 0,
title: {
text: 'millions'
}
},
legend: {
enabled: false
},
series: [{
name: …Run Code Online (Sandbox Code Playgroud) 我正在尝试在新窗口中以可读格式显示json。我有一个按钮,当您单击一个新选项卡时,其中会显示json。但是,在新窗口中,json仍未格式化,显示为纯文本。在中console.log,但是格式正确。我不明白为什么会有所不同。
$('.showRawJson').click(function () {
$.getJSON('somelink', function (json) {
var myjson = JSON.stringify(json, null, 2);
// In the console the json is well formatted
console.log(myjson);
var x = window.open();
x.document.open();
// Here in the new tab the json is NOT formatted
x.document.write(myjson);
x.document.close();
});
});
Run Code Online (Sandbox Code Playgroud)