Merge pull request #388 from roshanathomas/master
Content Negotiation Strategy - Removed HTML media type.
This commit is contained in:
commit
94c9d9567c
|
@ -23,14 +23,13 @@ public class ContentManagementWebConfig extends WebMvcConfigurerAdapter {
|
|||
|
||||
@Override
|
||||
public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) {
|
||||
configurer.favorPathExtension(true).
|
||||
favorParameter(false).
|
||||
configurer.favorPathExtension(false).
|
||||
favorParameter(true).
|
||||
parameterName("mediaType").
|
||||
ignoreAcceptHeader(true).
|
||||
useJaf(false).
|
||||
defaultContentType(MediaType.TEXT_HTML).
|
||||
defaultContentType(MediaType.APPLICATION_JSON).
|
||||
mediaType("xml", MediaType.APPLICATION_XML).
|
||||
mediaType("html", MediaType.TEXT_HTML).
|
||||
mediaType("json", MediaType.APPLICATION_JSON);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,15 +29,6 @@ public class EmployeeController {
|
|||
return employeeMap.get(Id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/employee/{Id}", method = RequestMethod.GET)
|
||||
public String getEmployeeByIdHtmlView(@PathVariable final long Id, final ModelMap model) {
|
||||
model.addAttribute("name", employeeMap.get(Id).getName());
|
||||
model.addAttribute("contactNumber", employeeMap.get(Id).getContactNumber());
|
||||
model.addAttribute("id", employeeMap.get(Id).getId());
|
||||
|
||||
return "employeeView";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addEmployee", method = RequestMethod.POST)
|
||||
public String submit(@ModelAttribute("employee") final Employee employee, final BindingResult result, final ModelMap model) {
|
||||
if (result.hasErrors()) {
|
||||
|
|
|
@ -30,15 +30,6 @@ public class EmployeeController {
|
|||
return employeeMap.get(Id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/employee/{Id}", method = RequestMethod.GET)
|
||||
public String getEmployeeByIdHtmlView(@PathVariable final long Id, final ModelMap model) {
|
||||
model.addAttribute("name", employeeMap.get(Id).getName());
|
||||
model.addAttribute("contactNumber", employeeMap.get(Id).getContactNumber());
|
||||
model.addAttribute("id", employeeMap.get(Id).getId());
|
||||
|
||||
return "employeeView";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addEmployee", method = RequestMethod.POST)
|
||||
public String submit(@ModelAttribute("employee") final Employee employee, final BindingResult result, final ModelMap model) {
|
||||
if (result.hasErrors()) {
|
||||
|
@ -47,9 +38,7 @@ public class EmployeeController {
|
|||
model.addAttribute("name", employee.getName());
|
||||
model.addAttribute("contactNumber", employee.getContactNumber());
|
||||
model.addAttribute("id", employee.getId());
|
||||
|
||||
employeeMap.put(employee.getId(), employee);
|
||||
|
||||
return "employeeView";
|
||||
}
|
||||
|
||||
|
|
|
@ -23,16 +23,15 @@
|
|||
<!-- Content strategy using path extension -->
|
||||
<bean id="contentNegotiationManager"
|
||||
class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
|
||||
<property name="favorPathExtension" value="true" />
|
||||
<property name="favorParameter" value="false"/>
|
||||
<property name="favorPathExtension" value="false" />
|
||||
<property name="favorParameter" value="true"/>
|
||||
<property name="parameterName" value="mediaType"/>
|
||||
<property name="ignoreAcceptHeader" value="true" />
|
||||
<property name="defaultContentType" value="text/html" />
|
||||
<property name="defaultContentType" value="application/json" />
|
||||
<property name="useJaf" value="false" />
|
||||
|
||||
<property name="mediaTypes">
|
||||
<map>
|
||||
<entry key="html" value="text/html" />
|
||||
<entry key="json" value="application/json" />
|
||||
<entry key="xml" value="application/xml" />
|
||||
</map>
|
||||
|
|
Loading…
Reference in New Issue