我有简单的POJO课程
public class Option {
String optionText;
public String getOptionText() {
return optionText;
}
public void setOptionText(String optionText) {
this.optionText = optionText;
}
@Override
public String toString() {
return optionText;
}
}
Run Code Online (Sandbox Code Playgroud)
在那里我正在创建一个Set对象,并希望将该对象转换为String [],我的逻辑是
public class Main {
Set<Option> options = new HashSet<Option>();
public Main() {
Option option1 = new Option();
option1.setOptionText("Option 1");
options.add(option1);
Option option2 = new Option();
option2.setOptionText("Option 2");
options.add(option2);
Option option3 = new Option();
option3.setOptionText("Option 3");
options.add(option3);
Option option4 = new Option();
option4.setOptionText("Option 4");
options.add(option4);
System.out.println("Set<Option> size …Run Code Online (Sandbox Code Playgroud) 我想json从JPA 生产@Entity,我有
@Entity
@JsonAutoDetect
public class Bar implements Serializable {
@Id
@GeneratedValue
private Integer id;
private String title;
//omitting other stuff
}
Run Code Online (Sandbox Code Playgroud)
我的控制器是
@RestController
public class BarController {
@Autowired
private BarService barService;
@RequestMapping(value = "/", method = RequestMethod.GET, headers = "Accept=application/json", produces={"application/json"})
public List<Bar> list() {
return barService.findAllBars());
}
}
Run Code Online (Sandbox Code Playgroud)
我在浏览器中遇到此错误
这有什么问题.
我有一个从url获取价值的问题,我有一个链接显示我的模态
<a href='#modal?userId=<%=resultSet.getInt("drid")%>' class="button-border toggleModal">Apportionment</a>
Run Code Online (Sandbox Code Playgroud)
上面的链接打开了模式,如下所示
<div id="modal" class="modal">
<header>
<h2>Appointment Form</h2>
</header>
<form action="addappoinment.jsp" method="post">
<input type="hidden" id="docId" name="docid" value=""><br>
<input type="text" required><br>
<input type="text" required><br>
<input type="text" required><br>
<input type="text" required><br>
<textarea rows="4" cols="21"></textarea><br>
<button class="button-border button-success" type="submit">
Done</button>
<button class="button-border button-error pull-right toggleModal">
Cancel</button>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
现在我有一个网址
http://localhost:8080/app/#modal?userId=1
Run Code Online (Sandbox Code Playgroud)
现在我想userId使用javascript 获取参数值
<script type="text/javascript">
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === …Run Code Online (Sandbox Code Playgroud)