@RequestMapping(value = {"/abcd", "/employees/{value}/{id}"})
public String getEmployees(
@PathVariable(value = "value") String val,
@PathVariable(value = "id") String id,
@RequestParam(value = "param", required = false) String value) {
// ********
}
Run Code Online (Sandbox Code Playgroud)
对于一个网址,我传递的是路径变量而一个我不是.但我希望这两个网址都能使用相同的API.我怎样才能实现它?
下面是我尝试使用的代码以及它给出的输出
RetValue: á, é, í, ó, ú, ü, ñ, ¿ Value: á, é, í, ó, ú, ü, ñ, ¿ ConvertValue: ?, ?, ?, ?, ?, ?, ?, ?
Run Code Online (Sandbox Code Playgroud)
这不是一个理想的输出,我认为这里的每个字符的输出应该是这种%C3%.请帮忙
public static void main(String[] args) {
String value = "á, é, í, ó, ú, ü, ñ, ¿";
String retValue = "";
String convertValue = "";
try {
retValue = new String(value.getBytes(),
Charset.forName("Windows-1252"));
convertValue = new String(retValue.getBytes("Windows-1252"),
Charset.forName("UTF-8"));
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("RetValue: " + retValue + " Value: …Run Code Online (Sandbox Code Playgroud) <tr class="rowsAdded">
<td><input name="item" class="form-control" type="text" placeholder="Item" /></td>
<td><input name="amount" class="form-control" type="number" placeholder="Amount" /></td>
<td><input name="expenseDate" class="form-control" type="date"placeholder="ExpenseDate" /></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
下面是我的控制器和Init Binder
@RequestMapping (value = "/saveExpenses", method=RequestMethod.POST)
public String saveExpenses (@RequestBody ExpenseDetailsListVO expenseDetailsListVO, Model model,BindingResult result) {
if (result.hasErrors()) {
System.out.println(result.getFieldError().getField().toString()+" error");
}
System.out.println(expenseDetailsListVO);
return "success";
}
@InitBinder
public void initBinder(WebDataBinder webDataBinder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(false);
webDataBinder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
Run Code Online (Sandbox Code Playgroud)
这样我想要的日期格式不起作用,这是输出我得到的 消费日期= 3月18日05:30:00 IST 2015 但是我希望它变成像yyyy-MM-dd这样的特定格式...建议我这样做的方法.
这是我在spring-servlet.xml中添加的内容
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="classpath:application"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
我的application.properties文件在src/main/resources文件夹中,但是我得到了这个异常
SEVERE: Servlet.service() for servlet [MVC-Dispatcher] in context with path [/MVCLayer] threw exception [javax.servlet.ServletException: javax.servlet.jsp.JspTagException: No message found under code 'Login_Username' for locale 'en_US'.] with root cause
javax.servlet.jsp.JspTagException: No message found under code 'Login_Username' for locale 'en_US'.
at org.springframework.web.servlet.tags.MessageTag.doEndTag(MessageTag.java:200)
Run Code Online (Sandbox Code Playgroud)
请帮忙解决配置有什么问题
假设我有一个Employee类,它具有另一个类的引用,表示具有自己属性的地址.所以请告诉我如何将其转换为xml文件,反之亦然.
谢谢!!