本文整理汇总了Java中org.springframework.web.accept.ContentNegotiationStrategy类的典型用法代码示例。如果您正苦于以下问题:Java ContentNegotiationStrategy类的具体用法?Java ContentNegotiationStrategy怎么用?Java ContentNegotiationStrategy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContentNegotiationStrategy类属于org.springframework.web.accept包,在下文中一共展示了ContentNegotiationStrategy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: commence
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
AuthenticationException authException) throws IOException, ServletException {
// if (LOG.isDebugEnabled()) {
// LOG.debug("Redirigiendo a pantalla de login: " + LOGIN_FORM_URL);
// }
ContentNegotiationStrategy negotiationStrategy = new HeaderContentNegotiationStrategy();
MediaTypeRequestMatcher matcher =
new MediaTypeRequestMatcher(negotiationStrategy, MediaType.TEXT_HTML);
matcher.setUseEquals(false);
if (matcher.matches(request)) {
DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
redirectStrategy.setContextRelative(false);
redirectStrategy.sendRedirect(request, response, LOGIN_FORM_URL);
} else {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
}
}
示例2: handle
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
@Override
public void handle(HttpServletRequest request, HttpServletResponse response,
AccessDeniedException accessDeniedException) throws IOException, ServletException {
ContentNegotiationStrategy negotiationStrategy = new HeaderContentNegotiationStrategy();
MediaTypeRequestMatcher matcher =
new MediaTypeRequestMatcher(negotiationStrategy, MediaType.TEXT_HTML);
matcher.setUseEquals(false);
if (matcher.matches(request)) {
DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
redirectStrategy.setContextRelative(false);
redirectStrategy.sendRedirect(request, response, "/errores/403");
} else {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
}
}
示例3: setUp
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
mockContentNegotiationStrategy = mock(ContentNegotiationStrategy.class);
when(mockContentNegotiationStrategy.resolveMediaTypes(any(NativeWebRequest.class))).thenReturn(Collections.<MediaType>emptyList());
exceptionResolver = new AjaxHandlerExceptionResolver();
mockUserContext = mock(UserContext.class);
mockPatientContext = mock(PatientContext.class);
mockEnvironment = mock(Environment.class);
exceptionResolver.setUserContext(mockUserContext);
exceptionResolver.setPatientContext(mockPatientContext);
exceptionResolver.setEnvironment(mockEnvironment);
exceptionResolver.setContentNegotiationStrategy(mockContentNegotiationStrategy);
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
}
示例4: initPathStrategy
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
private static PathExtensionContentNegotiationStrategy initPathStrategy(ContentNegotiationManager manager) {
for (ContentNegotiationStrategy strategy : manager.getStrategies()) {
if (strategy instanceof PathExtensionContentNegotiationStrategy) {
return (PathExtensionContentNegotiationStrategy) strategy;
}
}
return new PathExtensionContentNegotiationStrategy();
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:AbstractMessageConverterMethodProcessor.java
示例5: StationController
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
@Autowired
public StationController(IStreamingDao inStreamingDao, ICountDao inCountDao, ILogService inLogService,
@Qualifier("maxResultRows") Integer inMaxResultRows,
@Qualifier("stationWqx") IXmlMapping inXmlMapping,
@Qualifier("stationKml") IXmlMapping inKmlMapping,
@Qualifier("siteUrlBase") String inSiteUrlBase,
ContentNegotiationStrategy contentStrategy,
Validator validator) {
super(inStreamingDao, inCountDao, inLogService, inMaxResultRows, inSiteUrlBase, contentStrategy, validator);
xmlMapping = inXmlMapping;
kmlMapping = inKmlMapping;
}
示例6: ProjectController
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
@Autowired
public ProjectController(IStreamingDao inStreamingDao, ICountDao inCountDao, ILogService inLogService,
@Qualifier("maxResultRows") Integer inMaxResultRows,
@Qualifier("projectWqx") IXmlMapping inXmlMapping,
@Qualifier("siteUrlBase") String inSiteUrlBase,
ContentNegotiationStrategy inContentStrategy,
Validator validator) {
super(inStreamingDao, inCountDao, inLogService, inMaxResultRows, inSiteUrlBase, inContentStrategy, validator);
xmlMapping = inXmlMapping;
}
示例7: SimpleStationController
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
@Autowired
public SimpleStationController(IStreamingDao inStreamingDao, ICountDao inCountDao, ILogService inLogService,
@Qualifier("maxResultRows") Integer inMaxResultRows,
@Qualifier("simpleStationWqxOutbound") IXmlMapping inXmlMapping,
@Qualifier("siteUrlBase") String inSiteUrlBase,
ContentNegotiationStrategy contentStrategy,
Validator validator) {
super(inStreamingDao, inCountDao, inLogService, inMaxResultRows, inSiteUrlBase, contentStrategy, validator);
xmlMapping = inXmlMapping;
LOG.trace(getClass().getName());
}
示例8: ActivityMetricController
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
@Autowired
public ActivityMetricController(IStreamingDao inStreamingDao, ICountDao inCountDao, ILogService inLogService,
@Qualifier("maxResultRows") Integer inMaxResultRows,
@Qualifier("activityMetricWqx") IXmlMapping inXmlMapping,
@Qualifier("siteUrlBase") String inSiteUrlBase,
ContentNegotiationStrategy contentStrategy,
Validator validator) {
super(inStreamingDao, inCountDao, inLogService, inMaxResultRows, inSiteUrlBase, contentStrategy, validator);
xmlMapping = inXmlMapping;
}
示例9: BaseController
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
public BaseController(IStreamingDao inStreamingDao, ICountDao inCountDao, ILogService inLogService,
Integer inMaxResultRows, String inSiteUrlBase, ContentNegotiationStrategy inContentStrategy,
Validator inValidator) {
LOG.trace(getClass().getName());
streamingDao = inStreamingDao;
countDao = inCountDao;
logService = inLogService;
maxResultRows = inMaxResultRows;
siteUrlBase = inSiteUrlBase;
contentStrategy = inContentStrategy;
validator = inValidator;
}
示例10: ResDetectQntLmtController
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
@Autowired
public ResDetectQntLmtController(IStreamingDao inStreamingDao, ICountDao inCountDao, ILogService inLogService,
@Qualifier("maxResultRows") Integer inMaxResultRows,
@Qualifier("resDetectQntLmtWqx") IXmlMapping inXmlMapping,
@Qualifier("siteUrlBase") String inSiteUrlBase,
ContentNegotiationStrategy contentStrategy,
Validator validator) {
super(inStreamingDao, inCountDao, inLogService, inMaxResultRows, inSiteUrlBase, contentStrategy, validator);
xmlMapping = inXmlMapping;
}
示例11: ActivityController
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
@Autowired
public ActivityController(IStreamingDao inStreamingDao, ICountDao inCountDao, ILogService inLogService,
@Qualifier("maxResultRows") Integer inMaxResultRows,
@Qualifier("activityWqx") IXmlMapping inXmlMapping,
@Qualifier("siteUrlBase") String inSiteUrlBase,
ContentNegotiationStrategy contentStrategy,
Validator validator) {
super(inStreamingDao, inCountDao, inLogService, inMaxResultRows, inSiteUrlBase, contentStrategy, validator);
xmlMapping = inXmlMapping;
}
示例12: ResultController
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
@Autowired
public ResultController(IStreamingDao inStreamingDao, ICountDao inCountDao, ILogService inLogService,
@Qualifier("maxResultRows") Integer inMaxResultRows,
@Qualifier("resultWqx") IXmlMapping inXmlMapping,
@Qualifier("siteUrlBase") String inSiteUrlBase,
ContentNegotiationStrategy contentStrategy,
Validator validator) {
super(inStreamingDao, inCountDao, inLogService, inMaxResultRows, inSiteUrlBase, contentStrategy, validator);
xmlMapping = inXmlMapping;
}
示例13: TestBaseController
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
public TestBaseController(IStreamingDao inStreamingDao,
ICountDao inCountDao,
ILogService inLogService, Integer inMaxRows, String inSiteUrlBase,
ContentNegotiationStrategy contentStrategy,
Validator validator) {
super(inStreamingDao, inCountDao, inLogService, inMaxRows, inSiteUrlBase, contentStrategy, validator);
}
示例14: setContentNegotiationStrategy
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
@Required
public void setContentNegotiationStrategy(ContentNegotiationStrategy contentNegotiationStrategy) {
this.contentNegotiationStrategy = contentNegotiationStrategy;
}
示例15: defaultContentTypeStrategy
import org.springframework.web.accept.ContentNegotiationStrategy; //导入依赖的package包/类
/**
* Set a custom {@link ContentNegotiationStrategy} to use to determine
* the content type to use when no content type is requested.
* <p>By default this is not set.
* @see #defaultContentType
* @since 4.1.2
*/
public ContentNegotiationConfigurer defaultContentTypeStrategy(ContentNegotiationStrategy defaultStrategy) {
this.factory.setDefaultContentTypeStrategy(defaultStrategy);
return this;
}