Why does my JSF + Spring web application output JSF source code instead of interpreted HTML page?
- by Corvus
I'm new to both JSF and Spring Framework and I'm trying to figure out how to make them work together.
My current problem is that application outputs my JSF files without interpreting them.
Here are some snippets of my code which I believe might be relevant:
dispatcher-servlet.xml
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="login.htm">loginController</prop>
</props>
</property>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/pages/"
p:suffix=".xhtml" />
<bean name="loginController" class="controller.LoginController" />
loginController
public class LoginController extends MultiActionController {
public ModelAndView login(HttpServletRequest request,
HttpServletResponse response) throws Exception {
System.out.println("LOGIN");
return new ModelAndView("login");
}
WEB-INF/pages/login.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>#{message.log}</title>
</h:head>
<h:body>
<h:form>
<h:outputLabel value="#{message.username}" for="userName">
<h:inputText id="userName" value="#{User.name}" />
</h:outputLabel>
<h:commandButton value="#{message.loggin}" action="#{User.login}" />
</h:form>
</h:body>
</html>
Any ideas where the problem might be? Does this code make any sense at all? I'm well aware of fact, that probably completely sucks and I'll be glad to here WHY it sucks and how to make it better. Thanks :)